| 1 | |
|---|
| 2 | #include "DHL_OSAL.h" |
|---|
| 3 | |
|---|
| 4 | #include "cc_config.h" |
|---|
| 5 | #include "cc_def.h" |
|---|
| 6 | #include "cc_private.h" |
|---|
| 7 | |
|---|
| 8 | #define TICK_CUR OS_GetTickCount() |
|---|
| 9 | #define TICK_1SEC OS_GetTicksPerSecond() |
|---|
| 10 | #define TICK_10MS (TICK_1SEC/100) |
|---|
| 11 | #define TICK_PASS(s) (TICK_CUR-(s)) |
|---|
| 12 | |
|---|
| 13 | #define MAX_NUM_PIC_UD_Q 32 |
|---|
| 14 | |
|---|
| 15 | //configure... |
|---|
| 16 | |
|---|
| 17 | #define FONT_JUNGLE 0x1 |
|---|
| 18 | #define FONT_MLF 0x2 /* multi lanaguage font */ |
|---|
| 19 | |
|---|
| 20 | #define FONT_ID FONT_JUNGLE |
|---|
| 21 | |
|---|
| 22 | #define IS_FONT_JUNGLE (FONT_ID==FONT_JUNGLE) |
|---|
| 23 | #define IS_FONT_MLF (FONT_ID==FONT_MLF) |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | static tDCC_PicUDRaw p_ud_buf[MAX_NUM_PIC_UD_Q]; |
|---|
| 27 | |
|---|
| 28 | static OS_MESSAGEQUEUE_ID p_ud_msgq; |
|---|
| 29 | static int p_ud_buf_wr_idx=0; |
|---|
| 30 | static tDCC_UserCallback p_ud_callback; |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | #include "DHL_Graphic.h" |
|---|
| 34 | #include "DHL_AVCAP.h" |
|---|
| 35 | #include "DMG_Draw.h" |
|---|
| 36 | |
|---|
| 37 | #if IS_FONT_JUNGLE |
|---|
| 38 | #include "utfAPI.h" |
|---|
| 39 | #elif IS_FONT_MLF |
|---|
| 40 | #include "MLSupport.h" |
|---|
| 41 | #endif |
|---|
| 42 | |
|---|
| 43 | |
|---|
| 44 | |
|---|
| 45 | |
|---|
| 46 | #if 0 |
|---|
| 47 | __Local_Func__() {} |
|---|
| 48 | #endif |
|---|
| 49 | |
|---|
| 50 | static UINT16 p_remap_char(UINT16 ch) |
|---|
| 51 | { |
|---|
| 52 | UINT16 ret; |
|---|
| 53 | |
|---|
| 54 | switch(ch) { |
|---|
| 55 | case 0x121: |
|---|
| 56 | case 0x120: |
|---|
| 57 | ret=0x120; break; |
|---|
| 58 | |
|---|
| 59 | case 0x125: |
|---|
| 60 | case 0x12a: |
|---|
| 61 | case 0x12c: |
|---|
| 62 | case 0x130: |
|---|
| 63 | case 0x131: |
|---|
| 64 | case 0x132: |
|---|
| 65 | case 0x133: |
|---|
| 66 | case 0x134: |
|---|
| 67 | case 0x135: |
|---|
| 68 | case 0x139: |
|---|
| 69 | case 0x13a: |
|---|
| 70 | case 0x13c: |
|---|
| 71 | case 0x13d: |
|---|
| 72 | case 0x13f: |
|---|
| 73 | case 0x176: |
|---|
| 74 | case 0x177: |
|---|
| 75 | case 0x178: |
|---|
| 76 | case 0x179: |
|---|
| 77 | case 0x17a: |
|---|
| 78 | case 0x17b: |
|---|
| 79 | case 0x17c: |
|---|
| 80 | case 0x17d: |
|---|
| 81 | case 0x17e: |
|---|
| 82 | case 0x17f: |
|---|
| 83 | case 0x1a0: |
|---|
| 84 | ret=ch; break; |
|---|
| 85 | |
|---|
| 86 | default: |
|---|
| 87 | ret=0x20; |
|---|
| 88 | } |
|---|
| 89 | |
|---|
| 90 | return ret; |
|---|
| 91 | } |
|---|
| 92 | |
|---|
| 93 | |
|---|
| 94 | #if 0 |
|---|
| 95 | __Common__() {} |
|---|
| 96 | #endif |
|---|
| 97 | |
|---|
| 98 | |
|---|
| 99 | |
|---|
| 100 | #define OS_TICK2MS(tick) (tick*(1000/OS_GetTicksPerSecond())) |
|---|
| 101 | #define OS_MS2TICK(ms) (ms*OS_GetTicksPerSecond()/1000) |
|---|
| 102 | |
|---|
| 103 | |
|---|
| 104 | void *DCCDDI_Malloc(int size) |
|---|
| 105 | { |
|---|
| 106 | return malloc(size); |
|---|
| 107 | } |
|---|
| 108 | |
|---|
| 109 | |
|---|
| 110 | void DCCDDI_Printf(const char *fmt, ...) |
|---|
| 111 | { |
|---|
| 112 | char buf[512]; |
|---|
| 113 | va_list v; |
|---|
| 114 | |
|---|
| 115 | va_start(v, fmt); |
|---|
| 116 | |
|---|
| 117 | vsnprintf(buf, 512, fmt, v); |
|---|
| 118 | |
|---|
| 119 | va_end(v); |
|---|
| 120 | |
|---|
| 121 | printf("%s", buf); |
|---|
| 122 | } |
|---|
| 123 | |
|---|
| 124 | void DCCDDI_SpawnTask(void *func) |
|---|
| 125 | { |
|---|
| 126 | OS_SpawnTask((OS_TASKFUNCTION)func, "CC", TASK_PRI_DCC_DMX, 16384, 0); |
|---|
| 127 | } |
|---|
| 128 | |
|---|
| 129 | |
|---|
| 130 | tDCCDDI_MSGQ DCCDDI_CreateMessageQueue(char *pname, UINT32 num_msgq, UINT32 size_msgq) |
|---|
| 131 | { |
|---|
| 132 | return (tDCCDDI_MSGQ)OS_CreateMessageQueue(pname, 0, num_msgq, size_msgq); |
|---|
| 133 | } |
|---|
| 134 | |
|---|
| 135 | |
|---|
| 136 | tDCCDDI_SEM DCCDDI_CreateMutexSemaphore(char *pname) |
|---|
| 137 | { |
|---|
| 138 | return (tDCCDDI_SEM)OS_CreateMutexSemaphore(pname); |
|---|
| 139 | } |
|---|
| 140 | |
|---|
| 141 | |
|---|
| 142 | tDCCDDI_SEM DCCDDI_CreateBinarySemaphore(char *pname) |
|---|
| 143 | { |
|---|
| 144 | return (tDCCDDI_SEM)OS_CreateBinarySemaphore(pname, 0, 0); |
|---|
| 145 | } |
|---|
| 146 | |
|---|
| 147 | |
|---|
| 148 | void DCCDDI_SendMessage(tDCCDDI_MSGQ id, void *buf, UINT32 len) |
|---|
| 149 | { |
|---|
| 150 | OS_SendMessage((OS_MESSAGEQUEUE_ID)id, buf, len); |
|---|
| 151 | } |
|---|
| 152 | |
|---|
| 153 | |
|---|
| 154 | int DCCDDI_ReceiveMessage(tDCCDDI_MSGQ id, void *buf, UINT32 max_len, int *rcv_len) |
|---|
| 155 | { |
|---|
| 156 | return OS_ReceiveMessage((OS_MESSAGEQUEUE_ID)id, buf, max_len, rcv_len); |
|---|
| 157 | } |
|---|
| 158 | |
|---|
| 159 | |
|---|
| 160 | int DCCDDI_ReceiveMessage_Wait(tDCCDDI_MSGQ id, void *buf, UINT32 max_len, int *rcv_len, UINT32 msec) |
|---|
| 161 | { |
|---|
| 162 | return OS_ReceiveMessage_Wait((OS_MESSAGEQUEUE_ID)id, buf, max_len, rcv_len, OS_MS2TICK(msec)); |
|---|
| 163 | } |
|---|
| 164 | |
|---|
| 165 | int DCCDDI_ReceiveMessage_NoWait(tDCCDDI_MSGQ id, void *buf, UINT32 max_len, int *rcv_len) |
|---|
| 166 | { |
|---|
| 167 | return OS_ReceiveMessage_NoWait((OS_MESSAGEQUEUE_ID)id, buf, max_len, rcv_len); |
|---|
| 168 | } |
|---|
| 169 | |
|---|
| 170 | |
|---|
| 171 | void DCCDDI_TakeSemaphore(tDCCDDI_SEM id) |
|---|
| 172 | { |
|---|
| 173 | OS_TakeSemaphore((DHL_OS_SEMA_ID)id); |
|---|
| 174 | } |
|---|
| 175 | |
|---|
| 176 | void DCCDDI_GiveSemaphore(tDCCDDI_SEM id) |
|---|
| 177 | { |
|---|
| 178 | OS_GiveSemaphore((DHL_OS_SEMA_ID)id); |
|---|
| 179 | } |
|---|
| 180 | |
|---|
| 181 | void DCCDDI_Delay(UINT32 msec) |
|---|
| 182 | { |
|---|
| 183 | OS_Delay(OS_MS2TICK(msec)); |
|---|
| 184 | } |
|---|
| 185 | |
|---|
| 186 | UINT32 DCCDDI_GetCurMs() |
|---|
| 187 | { |
|---|
| 188 | return OS_TICK2MS(OS_GetTickCount()); |
|---|
| 189 | } |
|---|
| 190 | |
|---|
| 191 | |
|---|
| 192 | #if 0 |
|---|
| 193 | __Picture_User_Data__() {} |
|---|
| 194 | #endif |
|---|
| 195 | |
|---|
| 196 | |
|---|
| 197 | void DCCDDI_SetUserCallback(tDCC_UserCallback func) |
|---|
| 198 | { |
|---|
| 199 | p_ud_callback=func; |
|---|
| 200 | } |
|---|
| 201 | |
|---|
| 202 | |
|---|
| 203 | tDCC_PicUDRaw *DCCDDI_GetUserData() |
|---|
| 204 | { |
|---|
| 205 | int err; |
|---|
| 206 | int rcv_len; |
|---|
| 207 | int idx; |
|---|
| 208 | |
|---|
| 209 | err=OS_ReceiveMessage_Wait(p_ud_msgq, &idx, sizeof(idx), &rcv_len, TICK_10MS); |
|---|
| 210 | |
|---|
| 211 | if(err) return NULL; |
|---|
| 212 | |
|---|
| 213 | return &p_ud_buf[idx]; |
|---|
| 214 | } |
|---|
| 215 | |
|---|
| 216 | |
|---|
| 217 | static BOOL p_user_data(tDHL_AVCBType cb_type, tDHL_VideoContextHandle handle, UINT32 param) |
|---|
| 218 | { |
|---|
| 219 | tDHL_UserData *pud=(tDHL_UserData *)param; |
|---|
| 220 | |
|---|
| 221 | if(cb_type!=eDHL_CB_VDC_CCUDP) { |
|---|
| 222 | CCPRINT("warn", "!! %s : callback type is not cc callback\n"); |
|---|
| 223 | return FALSE; |
|---|
| 224 | } |
|---|
| 225 | |
|---|
| 226 | memcpy(p_ud_buf[p_ud_buf_wr_idx].data, pud->pdata, pud->hdr.payload_size); |
|---|
| 227 | p_ud_buf[p_ud_buf_wr_idx].size=pud->hdr.payload_size; |
|---|
| 228 | |
|---|
| 229 | p_ud_buf[p_ud_buf_wr_idx].pic_type=eDCC_PIC_CT_I;//pud->hdr.pic_coding; |
|---|
| 230 | |
|---|
| 231 | if(p_ud_callback) p_ud_callback(&p_ud_buf[p_ud_buf_wr_idx]); |
|---|
| 232 | |
|---|
| 233 | if(++p_ud_buf_wr_idx>=MAX_NUM_PIC_UD_Q) p_ud_buf_wr_idx=0; |
|---|
| 234 | |
|---|
| 235 | return TRUE; |
|---|
| 236 | } |
|---|
| 237 | |
|---|
| 238 | |
|---|
| 239 | int DCCDDI_Feeding608(BOOL is_even, UINT8 data1, UINT8 data2) |
|---|
| 240 | { |
|---|
| 241 | |
|---|
| 242 | return 0; |
|---|
| 243 | } |
|---|
| 244 | |
|---|
| 245 | #if 0 |
|---|
| 246 | __Graphic__() {} |
|---|
| 247 | #endif |
|---|
| 248 | |
|---|
| 249 | |
|---|
| 250 | |
|---|
| 251 | void DCCDDI_GraphicStart(UINT8 resolution) |
|---|
| 252 | { |
|---|
| 253 | DMG_SetFont(eDMG_FONT_JUNGLE); |
|---|
| 254 | } |
|---|
| 255 | |
|---|
| 256 | void DCCDDI_GraphicStop() |
|---|
| 257 | { |
|---|
| 258 | DMG_SetFont(eDMG_FONT_DHL_E2); |
|---|
| 259 | } |
|---|
| 260 | |
|---|
| 261 | void DCCDDI_DrawBox(int x, int y, int w, int h, int color) |
|---|
| 262 | { |
|---|
| 263 | CCPRINT("ddi", "DCCDDI_DrawBox(%d,%d,%d,%d,%d)\n", x, y, w, h, color); |
|---|
| 264 | |
|---|
| 265 | if(w<=0 || h<=0) return; |
|---|
| 266 | |
|---|
| 267 | DMG_EraseRect(x, y, w, h, color); |
|---|
| 268 | } |
|---|
| 269 | |
|---|
| 270 | //height°¡ -À̸é up, +À̸é down |
|---|
| 271 | void DCCDDI_BLT(int x, int y, int w, int h, int height) |
|---|
| 272 | { |
|---|
| 273 | CCPRINT("ddi", "DCCDDI_BLT(%d,%d,%d,%d,%d)\n", x, y, w, h, height); |
|---|
| 274 | |
|---|
| 275 | if(height==0 || h==0) return; |
|---|
| 276 | |
|---|
| 277 | tDHL_GrpRect r1, r2; |
|---|
| 278 | |
|---|
| 279 | DHL_FILLRECT(&r1, x, y, w, h); |
|---|
| 280 | DHL_FILLRECT(&r2, x, y+height, w, h); |
|---|
| 281 | |
|---|
| 282 | DMG_BLT(0, 0, &r1, &r2); |
|---|
| 283 | } |
|---|
| 284 | |
|---|
| 285 | void DCCDDI_DrawHLine(int x, int y, int w, int color) |
|---|
| 286 | { |
|---|
| 287 | if(w<=0) return; |
|---|
| 288 | |
|---|
| 289 | DMG_DrawHLine(x, y, w, color); |
|---|
| 290 | } |
|---|
| 291 | |
|---|
| 292 | |
|---|
| 293 | void DCCDDI_Refresh() |
|---|
| 294 | { |
|---|
| 295 | DMG_AutoRefresh(); |
|---|
| 296 | } |
|---|
| 297 | |
|---|
| 298 | |
|---|
| 299 | #if 0 |
|---|
| 300 | __Font__() {} |
|---|
| 301 | #endif |
|---|
| 302 | |
|---|
| 303 | #define USE_MARGINE 0 |
|---|
| 304 | |
|---|
| 305 | #if IS_FONT_JUNGLE |
|---|
| 306 | static UT_FC p_reg_fc; |
|---|
| 307 | #elif IS_FONT_MLF |
|---|
| 308 | static RML_FC p_reg_fc; |
|---|
| 309 | #endif |
|---|
| 310 | |
|---|
| 311 | |
|---|
| 312 | static struct { |
|---|
| 313 | int size; |
|---|
| 314 | BOOL is_italic; |
|---|
| 315 | BOOL is_underline; |
|---|
| 316 | BOOL is_unicode; //2byte. ÇѱÛÀÎ °æ¿ì unicode/¿Ï¼ºÇü Áß ¾î´À °ÍÀÎÁö.. |
|---|
| 317 | BOOL is_p16; |
|---|
| 318 | int font_style; |
|---|
| 319 | int edge_type; |
|---|
| 320 | } p_font_attr; |
|---|
| 321 | |
|---|
| 322 | |
|---|
| 323 | int DCCDDI_PrintCh(int x, int y, UINT16 ch, int c_font, int c_edge) |
|---|
| 324 | { |
|---|
| 325 | tDMG_FontAttr attr; |
|---|
| 326 | int width; |
|---|
| 327 | |
|---|
| 328 | if(!p_font_attr.is_unicode) { |
|---|
| 329 | //¿Ï¼ºÇüÀ» unicode·Î º¯°æÇÔ. |
|---|
| 330 | ch=DCCUtil_Ksx1001toUnicode(ch); |
|---|
| 331 | CCPRINT("ddi", "convert to ksx1001(0x%x)\n", ch); |
|---|
| 332 | } |
|---|
| 333 | |
|---|
| 334 | DMG_GetFontAttr(&attr); |
|---|
| 335 | attr.c_edge=c_edge; |
|---|
| 336 | DMG_SetFontAttr(&attr); |
|---|
| 337 | |
|---|
| 338 | width=DMG_PrintCh(x, y, ch, c_font); |
|---|
| 339 | |
|---|
| 340 | return width; |
|---|
| 341 | } |
|---|
| 342 | |
|---|
| 343 | |
|---|
| 344 | int DCCDDI_GetChWidth(UINT16 ch) |
|---|
| 345 | { |
|---|
| 346 | if(!p_font_attr.is_unicode) { |
|---|
| 347 | //¿Ï¼ºÇüÀ» unicode·Î º¯°æÇÔ. |
|---|
| 348 | CCPRINT("ddi_ch", "convert to ksx1001(0x%x->0x%x)\n", ch, DCCUtil_Ksx1001toUnicode(ch)); |
|---|
| 349 | ch=DCCUtil_Ksx1001toUnicode(ch); |
|---|
| 350 | } |
|---|
| 351 | |
|---|
| 352 | return DMG_GetChWidth(ch); |
|---|
| 353 | } |
|---|
| 354 | |
|---|
| 355 | |
|---|
| 356 | int DCCDDI_GetChHeight(UINT16 ch) |
|---|
| 357 | { |
|---|
| 358 | if(!p_font_attr.is_unicode) { |
|---|
| 359 | //¿Ï¼ºÇüÀ» unicode·Î º¯°æÇÔ. |
|---|
| 360 | CCPRINT("ddi_ch", "convert to ksx1001(0x%x)\n", ch); |
|---|
| 361 | ch=DCCUtil_Ksx1001toUnicode(ch); |
|---|
| 362 | } |
|---|
| 363 | |
|---|
| 364 | return DMG_GetChHeight(ch); |
|---|
| 365 | } |
|---|
| 366 | |
|---|
| 367 | |
|---|
| 368 | void DCCDDI_SetFontAttr(int size, BOOL is_italic, BOOL is_underline, UINT8 font_style, |
|---|
| 369 | UINT8 edge_type, BOOL is_p16) |
|---|
| 370 | { |
|---|
| 371 | tDMG_FontAttr attr; |
|---|
| 372 | |
|---|
| 373 | DMG_GetFontAttr(&attr); |
|---|
| 374 | |
|---|
| 375 | attr.size=size; |
|---|
| 376 | attr.is_italic=is_italic; |
|---|
| 377 | attr.is_underline=is_underline; |
|---|
| 378 | |
|---|
| 379 | if(is_p16) { |
|---|
| 380 | attr.font_style=eDCC_FS_KOREAN; |
|---|
| 381 | } |
|---|
| 382 | else { |
|---|
| 383 | attr.font_style=font_style; |
|---|
| 384 | } |
|---|
| 385 | |
|---|
| 386 | attr.edge_type=edge_type; |
|---|
| 387 | |
|---|
| 388 | DMG_SetFontAttr(&attr); |
|---|
| 389 | |
|---|
| 390 | } |
|---|
| 391 | |
|---|
| 392 | |
|---|
| 393 | |
|---|
| 394 | #if 0 |
|---|
| 395 | __Init__() {} |
|---|
| 396 | #endif |
|---|
| 397 | |
|---|
| 398 | |
|---|
| 399 | |
|---|
| 400 | void DCCDDI_Init() |
|---|
| 401 | { |
|---|
| 402 | p_ud_msgq=OS_CreateMessageQueue("udmsgq", 0, MAX_NUM_PIC_UD_Q, sizeof(int)); |
|---|
| 403 | |
|---|
| 404 | #if IS_FONT_JUNGLE |
|---|
| 405 | ut_InitFontContext(&p_reg_fc, 0, 0); |
|---|
| 406 | #elif IS_FONT_MLF |
|---|
| 407 | RML_InitFontContext(&p_reg_fc, 0, 0); |
|---|
| 408 | #endif |
|---|
| 409 | |
|---|
| 410 | DHL_AV_PresetCallback(p_user_data, eDHL_CB_VDC_CCUDP, 0); |
|---|
| 411 | } |
|---|
| 412 | |
|---|
| 413 | void DCCDDI_SetKoreanMode(BOOL is_unicode) |
|---|
| 414 | { |
|---|
| 415 | |
|---|
| 416 | } |
|---|
| 417 | |
|---|
| 418 | |
|---|
| 419 | #if 0 |
|---|
| 420 | ___Debug___() |
|---|
| 421 | #endif |
|---|
| 422 | |
|---|
| 423 | void cc_ddi_info() |
|---|
| 424 | { |
|---|
| 425 | |
|---|
| 426 | } |
|---|