| 1 | /****************************************************************************** |
|---|
| 2 | *_Copyright (c) 2009 Digital Stream Technology Inc. All Rights Reserved. |
|---|
| 3 | * |
|---|
| 4 | * Module: dstdddisp.c |
|---|
| 5 | * |
|---|
| 6 | * Description |
|---|
| 7 | * This file includes platform/vendor specific APIs. |
|---|
| 8 | * |
|---|
| 9 | * @author Junku Park (hwatk@dstreamtech.com) |
|---|
| 10 | * @version $Revision: 1.1 $ |
|---|
| 11 | * |
|---|
| 12 | ******************************************************************************/ |
|---|
| 13 | #include <stdlib.h> |
|---|
| 14 | #include <fcntl.h> |
|---|
| 15 | #include <getopt.h> |
|---|
| 16 | #include <sys/ioctl.h> |
|---|
| 17 | #include <sys/time.h> |
|---|
| 18 | #include <string.h> |
|---|
| 19 | #include <errno.h> |
|---|
| 20 | |
|---|
| 21 | #include "dsthalcommon.h" |
|---|
| 22 | #include "dstoslayer.h" |
|---|
| 23 | |
|---|
| 24 | #include "dstdddtv.h" |
|---|
| 25 | #include "dstddcap.h" |
|---|
| 26 | #include "dstdddisp.h" |
|---|
| 27 | #include "dstddsys.h" |
|---|
| 28 | #include "panel_data.h" |
|---|
| 29 | |
|---|
| 30 | #ifdef DMALLOC |
|---|
| 31 | #include <dmalloc.h> |
|---|
| 32 | #endif |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | /****************************************************************************** |
|---|
| 36 | * Global variable declaration |
|---|
| 37 | ******************************************************************************/ |
|---|
| 38 | |
|---|
| 39 | /****************************************************************************** |
|---|
| 40 | * Imported variable declaration |
|---|
| 41 | ******************************************************************************/ |
|---|
| 42 | |
|---|
| 43 | /****************************************************************************** |
|---|
| 44 | * Imported function declaration |
|---|
| 45 | ******************************************************************************/ |
|---|
| 46 | |
|---|
| 47 | /****************************************************************************** |
|---|
| 48 | * Local definitions |
|---|
| 49 | ******************************************************************************/ |
|---|
| 50 | #define CONV_TO_BASE(r,v,b) do { (v) *= (b)*100; (v) /= (100); (v) = (((v)%(b)) >= (b>>1)) ? (v)-((v)%(b))+(b) : (v)-((v)%(b)); (r) = (v)/100; } while(0); |
|---|
| 51 | #define CONV_TO_100(r,v,b) do { (v) *= 10000; (v) /= (b); (v) = (((v)%100) >= 50) ? (v)-((v)%100)+100 : (v)-((v)%100); (r) = (v)/100; } while(0); |
|---|
| 52 | |
|---|
| 53 | #define PANELPOWER_TASK_PRIORITY 90 |
|---|
| 54 | #define PANELPOWER_TASK_STACKSIZE 16384 |
|---|
| 55 | #define MAX_PP_MESSAGES 120 |
|---|
| 56 | |
|---|
| 57 | /****************************************************************************** |
|---|
| 58 | * Local typedefs |
|---|
| 59 | ******************************************************************************/ |
|---|
| 60 | |
|---|
| 61 | /****************************************************************************** |
|---|
| 62 | * Local variables declaration |
|---|
| 63 | ******************************************************************************/ |
|---|
| 64 | static PanelConfig_t *CurrentPanel = 0; |
|---|
| 65 | static OS_MESSAGEQUEUE_ID PanelPowerQ; |
|---|
| 66 | static OS_TASK_ID PanelPowerTaskId; |
|---|
| 67 | static int tPanelPowerStarted = 0; |
|---|
| 68 | |
|---|
| 69 | /****************************************************************************** |
|---|
| 70 | * Local function prototypes |
|---|
| 71 | ******************************************************************************/ |
|---|
| 72 | static int PanelPowerReq(int Arg); |
|---|
| 73 | DHL_RESULT DD_DISP_SetVideoMuteColor(DS_U8 red, DS_U8 green, DS_U8 blue); |
|---|
| 74 | |
|---|
| 75 | |
|---|
| 76 | #if 0 |
|---|
| 77 | ___General_Display_Functions___() |
|---|
| 78 | #endif |
|---|
| 79 | DHL_RESULT DD_DISP_Init(void) |
|---|
| 80 | { |
|---|
| 81 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 82 | |
|---|
| 83 | dhlResult = DD_DISP_SetVideoMuteColor(0x80, 0x00, 0x80); |
|---|
| 84 | SysASSERT( dhlResult == DHL_OK ); |
|---|
| 85 | |
|---|
| 86 | CurrentPanel = &PanelData_LC420W01; |
|---|
| 87 | |
|---|
| 88 | return dhlResult; |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | DHL_RESULT DD_DISP_ChangeVideoFormat(DHL_VIDEO_FORMAT UserVidFormat) |
|---|
| 92 | { |
|---|
| 93 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 94 | |
|---|
| 95 | return dhlResult; |
|---|
| 96 | } |
|---|
| 97 | |
|---|
| 98 | DHL_RESULT DD_DISP_SetAspectRatio(int Aspect) |
|---|
| 99 | { |
|---|
| 100 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 101 | |
|---|
| 102 | return dhlResult; |
|---|
| 103 | } |
|---|
| 104 | |
|---|
| 105 | DHL_RESULT DD_DISP_SetPIPLocation(DHL_PIP_t PipLocation) |
|---|
| 106 | { |
|---|
| 107 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 108 | |
|---|
| 109 | return dhlResult; |
|---|
| 110 | } |
|---|
| 111 | |
|---|
| 112 | DHL_RESULT DD_DISP_SetPIPStyle(DHL_PIPMode_t PipMode, DHL_PIP_t PipLocation) |
|---|
| 113 | { |
|---|
| 114 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 115 | |
|---|
| 116 | return dhlResult; |
|---|
| 117 | } |
|---|
| 118 | |
|---|
| 119 | void DD_DISP_ResetOutput(void) |
|---|
| 120 | { |
|---|
| 121 | /* |
|---|
| 122 | * Display Output RESET. |
|---|
| 123 | * Just for special cases such as HDMI output reset. |
|---|
| 124 | */ |
|---|
| 125 | |
|---|
| 126 | } |
|---|
| 127 | |
|---|
| 128 | #if 0 |
|---|
| 129 | ___MUTE_APIs___() |
|---|
| 130 | #endif |
|---|
| 131 | static DS_U8 muteColorRed=0x00; |
|---|
| 132 | static DS_U8 muteColorGreen=0x00; |
|---|
| 133 | static DS_U8 muteColorBlue=0x00; |
|---|
| 134 | DHL_RESULT DD_DISP_SetVideoMuteColor(DS_U8 red, DS_U8 green, DS_U8 blue) |
|---|
| 135 | { |
|---|
| 136 | muteColorRed=red; |
|---|
| 137 | muteColorGreen=green; |
|---|
| 138 | muteColorBlue=blue; |
|---|
| 139 | |
|---|
| 140 | return DHL_OK; |
|---|
| 141 | } |
|---|
| 142 | |
|---|
| 143 | #if MUTE_DEBUG |
|---|
| 144 | DHL_RESULT DD_DISP_VideoMute_Internal(DS_BOOL uMute, const char *Fname, int Line) |
|---|
| 145 | #else |
|---|
| 146 | DHL_RESULT DD_DISP_VideoMute(DS_BOOL uMute) |
|---|
| 147 | #endif |
|---|
| 148 | { |
|---|
| 149 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 150 | |
|---|
| 151 | return dhlResult; |
|---|
| 152 | } |
|---|
| 153 | |
|---|
| 154 | DHL_RESULT DD_DISP_VideoMutePIP(DS_BOOL uMute) |
|---|
| 155 | { |
|---|
| 156 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 157 | |
|---|
| 158 | return dhlResult; |
|---|
| 159 | } |
|---|
| 160 | |
|---|
| 161 | DHL_RESULT DD_DISP_VideoMuteCVBS(DS_BOOL uMute) |
|---|
| 162 | { |
|---|
| 163 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 164 | |
|---|
| 165 | return dhlResult; |
|---|
| 166 | } |
|---|
| 167 | |
|---|
| 168 | |
|---|
| 169 | #if 0 |
|---|
| 170 | ___PANEL_Functions___() |
|---|
| 171 | #endif |
|---|
| 172 | DHL_RESULT DD_DISP_SetLCDBacklight(DS_U16 uiDeg) |
|---|
| 173 | { |
|---|
| 174 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 175 | |
|---|
| 176 | return dhlResult; |
|---|
| 177 | } |
|---|
| 178 | |
|---|
| 179 | void DD_DISP_SetPanelPower_Internal( DS_BOOL OnOff ); |
|---|
| 180 | |
|---|
| 181 | static int tPanelPower(DS_U32 *arg) |
|---|
| 182 | { |
|---|
| 183 | static DS_U32 Msg[2]; |
|---|
| 184 | DS_U32 msgLen; |
|---|
| 185 | DS_U32 ret; |
|---|
| 186 | |
|---|
| 187 | while(1) |
|---|
| 188 | { |
|---|
| 189 | if ( tPanelPowerStarted == 0 ) |
|---|
| 190 | { |
|---|
| 191 | OS_mDelay(100); |
|---|
| 192 | continue; |
|---|
| 193 | } |
|---|
| 194 | |
|---|
| 195 | ret = OS_ReceiveMessage(PanelPowerQ, Msg, sizeof(DS_U32), &msgLen); |
|---|
| 196 | if ( ret ) |
|---|
| 197 | { |
|---|
| 198 | DHL_DbgPrintf(0,DDDBG_AV,"ERROR, LINE=%d\n", __LINE__); |
|---|
| 199 | continue; |
|---|
| 200 | } |
|---|
| 201 | |
|---|
| 202 | DD_DISP_SetPanelPower_Internal(Msg[0]); |
|---|
| 203 | OS_mDelay(100); |
|---|
| 204 | } |
|---|
| 205 | } |
|---|
| 206 | |
|---|
| 207 | static DHL_RESULT PanelPowerStart(void) |
|---|
| 208 | { |
|---|
| 209 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 210 | |
|---|
| 211 | if ( tPanelPowerStarted == 1 ) |
|---|
| 212 | return dhlResult; |
|---|
| 213 | |
|---|
| 214 | tPanelPowerStarted = 1; |
|---|
| 215 | |
|---|
| 216 | return dhlResult; |
|---|
| 217 | } |
|---|
| 218 | static DHL_RESULT PanelPowerInit(void) |
|---|
| 219 | { |
|---|
| 220 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 221 | static int init = 0; |
|---|
| 222 | |
|---|
| 223 | if ( init == 1 ) |
|---|
| 224 | return dhlResult; |
|---|
| 225 | |
|---|
| 226 | init = 1; |
|---|
| 227 | PanelPowerQ = OS_CreateMessageQueue("q_PanelPower", 0, MAX_PP_MESSAGES, sizeof(DS_U32)); |
|---|
| 228 | if ( PanelPowerQ == (DS_U32)NULL ) |
|---|
| 229 | { |
|---|
| 230 | dhlResult = DHL_FAIL_OUT_OF_RESOURCE; |
|---|
| 231 | goto done; |
|---|
| 232 | } |
|---|
| 233 | |
|---|
| 234 | PanelPowerTaskId = OS_SpawnTask( (void (*) (DS_U32))tPanelPower, "tPanelPowerTask", |
|---|
| 235 | PANELPOWER_TASK_PRIORITY, PANELPOWER_TASK_STACKSIZE, 0 ); |
|---|
| 236 | if ( PanelPowerTaskId == (DS_U32)NULL ) |
|---|
| 237 | { |
|---|
| 238 | dhlResult = DHL_FAIL_OUT_OF_RESOURCE; |
|---|
| 239 | goto done; |
|---|
| 240 | } |
|---|
| 241 | |
|---|
| 242 | PanelPowerStart(); |
|---|
| 243 | done: |
|---|
| 244 | |
|---|
| 245 | return dhlResult; |
|---|
| 246 | } |
|---|
| 247 | |
|---|
| 248 | static int PanelPowerReq(int Arg) |
|---|
| 249 | { |
|---|
| 250 | DS_U32 Msg[2]; |
|---|
| 251 | |
|---|
| 252 | Msg[0] = Arg; |
|---|
| 253 | if ( OS_SendMessage(PanelPowerQ, (DS_U32 *)Msg, sizeof(DS_U32)) ) |
|---|
| 254 | { |
|---|
| 255 | DHL_DbgPrintf(0,DDDBG_AV,"Cannot send msg AudioMute Thread.\n"); |
|---|
| 256 | DstCore_QueueReset(PanelPowerQ); |
|---|
| 257 | return -1; |
|---|
| 258 | } |
|---|
| 259 | |
|---|
| 260 | return 0; |
|---|
| 261 | } |
|---|
| 262 | |
|---|
| 263 | |
|---|
| 264 | DHL_RESULT DD_DISP_SetPanelPower( DS_BOOL OnOff ) |
|---|
| 265 | { |
|---|
| 266 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 267 | |
|---|
| 268 | if (tPanelPowerStarted != 1) |
|---|
| 269 | { |
|---|
| 270 | PanelPowerInit(); |
|---|
| 271 | } |
|---|
| 272 | |
|---|
| 273 | if ( PanelPowerReq( OnOff ) < 0 ) |
|---|
| 274 | dhlResult = DHL_FAIL; |
|---|
| 275 | |
|---|
| 276 | return dhlResult; |
|---|
| 277 | } |
|---|
| 278 | |
|---|
| 279 | void DD_DISP_SetPanelPower_Internal( DS_BOOL OnOff ) |
|---|
| 280 | { |
|---|
| 281 | |
|---|
| 282 | } |
|---|
| 283 | |
|---|
| 284 | DHL_RESULT DD_DISP_GetPanelPowerStatus(void) |
|---|
| 285 | { |
|---|
| 286 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 287 | |
|---|
| 288 | return dhlResult; |
|---|
| 289 | } |
|---|
| 290 | |
|---|
| 291 | DHL_RESULT DD_DISP_GetDimmingDelay(DS_BOOL onoff, DS_S32 *Delay, DS_S32 *Delay2) |
|---|
| 292 | { |
|---|
| 293 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 294 | |
|---|
| 295 | return dhlResult; |
|---|
| 296 | } |
|---|
| 297 | |
|---|
| 298 | DHL_RESULT DD_DISP_GetBacklightOnOffStatus(void) |
|---|
| 299 | { |
|---|
| 300 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 301 | |
|---|
| 302 | return dhlResult; |
|---|
| 303 | } |
|---|
| 304 | |
|---|
| 305 | #if 0 |
|---|
| 306 | ___LVDS_APIs___() |
|---|
| 307 | #endif |
|---|
| 308 | void DD_DISP_SetLVDSClockFreq(int Offset) |
|---|
| 309 | { |
|---|
| 310 | } |
|---|
| 311 | |
|---|
| 312 | void DD_DISP_SetLVDSClockPhase(int Offset) |
|---|
| 313 | { |
|---|
| 314 | } |
|---|
| 315 | |
|---|
| 316 | int DD_DISP_GetLVDSClockFreq(void) |
|---|
| 317 | { |
|---|
| 318 | return 0; |
|---|
| 319 | } |
|---|
| 320 | |
|---|
| 321 | int DD_DISP_GetLVDSClockPhase(void) |
|---|
| 322 | { |
|---|
| 323 | return 0; |
|---|
| 324 | } |
|---|
| 325 | |
|---|
| 326 | #if 0 |
|---|
| 327 | ___SIDE_COLOR_APIs___() |
|---|
| 328 | #endif |
|---|
| 329 | DHL_RESULT DD_DISP_SetSideColorEnable(int En) |
|---|
| 330 | { |
|---|
| 331 | |
|---|
| 332 | return DHL_OK; |
|---|
| 333 | } |
|---|
| 334 | |
|---|
| 335 | DHL_RESULT DD_DISP_GetSideColorEnable(int *pEn) |
|---|
| 336 | { |
|---|
| 337 | |
|---|
| 338 | return DHL_OK; |
|---|
| 339 | } |
|---|
| 340 | |
|---|
| 341 | DHL_RESULT DD_DISP_SetSideColor(DS_U8 R, DS_U8 G, DS_U8 B) |
|---|
| 342 | { |
|---|
| 343 | |
|---|
| 344 | return DHL_OK; |
|---|
| 345 | } |
|---|
| 346 | |
|---|
| 347 | DHL_RESULT DD_DISP_GetSideColor(DS_U8 *pR, DS_U8 *pG, DS_U8 *pB) |
|---|
| 348 | { |
|---|
| 349 | |
|---|
| 350 | return DHL_OK; |
|---|
| 351 | } |
|---|
| 352 | |
|---|
| 353 | #if 0 |
|---|
| 354 | ___CVBS_OUTPUT_APIs___() |
|---|
| 355 | #endif |
|---|
| 356 | DHL_RESULT DD_DISP_EmbedCC(int nField, DS_U32 data0, DS_U32 data1) |
|---|
| 357 | { |
|---|
| 358 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 359 | |
|---|
| 360 | return dhlResult; |
|---|
| 361 | } |
|---|
| 362 | |
|---|
| 363 | DHL_RESULT DD_DISP_InitAuxCC(void) |
|---|
| 364 | { |
|---|
| 365 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 366 | |
|---|
| 367 | return dhlResult; |
|---|
| 368 | } |
|---|
| 369 | |
|---|
| 370 | DHL_RESULT DD_DISP_EnableAuxCC(int Enable) |
|---|
| 371 | { |
|---|
| 372 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 373 | |
|---|
| 374 | return dhlResult; |
|---|
| 375 | } |
|---|