1/* Copyright (c) 2005 Advanced Micro Devices, Inc. 2 * 3 * Permission is hereby granted, free of charge, to any person obtaining a copy 4 * of this software and associated documentation files (the "Software"), to 5 * deal in the Software without restriction, including without limitation the 6 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 * sell copies of the Software, and to permit persons to whom the Software is 8 * furnished to do so, subject to the following conditions: 9 * 10 * The above copyright notice and this permission notice shall be included in 11 * all copies or substantial portions of the Software. 12 * 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 * IN THE SOFTWARE. 20 * 21 * Neither the name of the Advanced Micro Devices, Inc. nor the names of its 22 * contributors may be used to endorse or promote products derived from this 23 * software without specific prior written permission. 24 * */ 25 26/* 27 * This file contains routines to control the video decoder. 28 * 29 * gfx_set_decoder_defaults 30 * gfx_set_decoder_analog_input 31 * gfx_set_decoder_brightness 32 * gfx_set_decoder_contrast 33 * gfx_set_decoder_luminance_filter 34 * gfx_set_decoder_hue 35 * gfx_set_decoder_saturation 36 * gfx_set_decoder_input_offset 37 * gfx_set_decoder_input_size 38 * gfx_set_decoder_output_size 39 * gfx_set_decoder_scale 40 * gfx_set_decoder_TV_standard 41 * gfx_set_decoder_vbi_enable 42 * gfx_set_decoder_vbi_format 43 * gfx_set_decoder_vbi_upscale 44 * gfx_decoder_software_reset 45 * gfx_decoder_detect_macrovision 46 * gfx_decoder_detect_video 47 * 48 * And the following routines if GFX_READ_ROUTINES is set: 49 * 50 * gfx_get_decoder_brightness 51 * gfx_get_decoder_contrast 52 * gfx_get_decoder_hue 53 * gfx_get_decoder_saturation 54 * gfx_get_decoder_input_offset 55 * gfx_get_decoder_input_size 56 * gfx_get_decoder_output_size 57 * gfx_get_decoder_vbi_format 58 */ 59 60/* INCLUDE SUPPORT FOR PHILIPS SAA7114 DECODER, IF SPECIFIED */ 61 62#if GFX_DECODER_SAA7114 63#include "saa7114.c" 64#endif 65 66/* WRAPPERS IF DYNAMIC SELECTION */ 67/* Extra layer to call various decoders. Currently only the Pillips */ 68/* decoder is supported, but still organized to easily expand later. */ 69 70#if GFX_DECODER_DYNAMIC 71 72/*---------------------------------------------------------------------------- 73 * gfx_set_decoder_defaults 74 *---------------------------------------------------------------------------- 75 */ 76int 77gfx_set_decoder_defaults(void) 78{ 79 int status = GFX_STATUS_UNSUPPORTED; 80 81#if GFX_DECODER_SAA7114 82 if (gfx_decoder_type == GFX_DECODER_SAA7114) 83 status = saa7114_set_decoder_defaults(); 84#endif 85 return (status); 86} 87 88/*---------------------------------------------------------------------------- 89 * gfx_set_decoder_analog_input 90 *---------------------------------------------------------------------------- 91 */ 92int 93gfx_set_decoder_analog_input(unsigned char input) 94{ 95 int status = GFX_STATUS_UNSUPPORTED; 96 97#if GFX_DECODER_SAA7114 98 if (gfx_decoder_type == GFX_DECODER_SAA7114) 99 status = saa7114_set_decoder_analog_input(input); 100#endif 101 return (status); 102} 103 104/*---------------------------------------------------------------------------- 105 * gfx_set_decoder_brightness 106 *---------------------------------------------------------------------------- 107 */ 108int 109gfx_set_decoder_brightness(unsigned char brightness) 110{ 111 int status = GFX_STATUS_UNSUPPORTED; 112 113#if GFX_DECODER_SAA7114 114 if (gfx_decoder_type == GFX_DECODER_SAA7114) 115 status = saa7114_set_decoder_brightness(brightness); 116#endif 117 return (status); 118} 119 120/*---------------------------------------------------------------------------- 121 * gfx_set_decoder_contrast 122 *---------------------------------------------------------------------------- 123 */ 124int 125gfx_set_decoder_contrast(unsigned char contrast) 126{ 127 int status = GFX_STATUS_UNSUPPORTED; 128 129#if GFX_DECODER_SAA7114 130 if (gfx_decoder_type == GFX_DECODER_SAA7114) 131 status = saa7114_set_decoder_contrast(contrast); 132#endif 133 return (status); 134} 135 136/*---------------------------------------------------------------------------- 137 * gfx_set_decoder_hue 138 *---------------------------------------------------------------------------- 139 */ 140int 141gfx_set_decoder_hue(char hue) 142{ 143 int status = GFX_STATUS_UNSUPPORTED; 144 145#if GFX_DECODER_SAA7114 146 if (gfx_decoder_type == GFX_DECODER_SAA7114) 147 status = saa7114_set_decoder_hue(hue); 148#endif 149 return (status); 150} 151 152/*---------------------------------------------------------------------------- 153 * gfx_set_decoder_saturation 154 *---------------------------------------------------------------------------- 155 */ 156int 157gfx_set_decoder_saturation(unsigned char saturation) 158{ 159 int status = GFX_STATUS_UNSUPPORTED; 160 161#if GFX_DECODER_SAA7114 162 if (gfx_decoder_type == GFX_DECODER_SAA7114) 163 status = saa7114_set_decoder_saturation(saturation); 164#endif 165 return (status); 166} 167 168/*---------------------------------------------------------------------------- 169 * gfx_set_decoder_input_offset 170 *---------------------------------------------------------------------------- 171 */ 172int 173gfx_set_decoder_input_offset(unsigned short x, unsigned short y) 174{ 175 int status = GFX_STATUS_UNSUPPORTED; 176 177#if GFX_DECODER_SAA7114 178 if (gfx_decoder_type == GFX_DECODER_SAA7114) 179 status = saa7114_set_decoder_input_offset(x, y); 180#endif 181 return (status); 182} 183 184/*---------------------------------------------------------------------------- 185 * gfx_set_decoder_input_size 186 *---------------------------------------------------------------------------- 187 */ 188int 189gfx_set_decoder_input_size(unsigned short width, unsigned short height) 190{ 191 int status = GFX_STATUS_UNSUPPORTED; 192 193#if GFX_DECODER_SAA7114 194 if (gfx_decoder_type == GFX_DECODER_SAA7114) 195 status = saa7114_set_decoder_input_size(width, height); 196#endif 197 return (status); 198} 199 200/*---------------------------------------------------------------------------- 201 * gfx_set_decoder_output_size 202 *---------------------------------------------------------------------------- 203 */ 204int 205gfx_set_decoder_output_size(unsigned short width, unsigned short height) 206{ 207 int status = GFX_STATUS_UNSUPPORTED; 208 209#if GFX_DECODER_SAA7114 210 if (gfx_decoder_type == GFX_DECODER_SAA7114) 211 status = saa7114_set_decoder_output_size(width, height); 212#endif 213 return (status); 214} 215 216/*---------------------------------------------------------------------------- 217 * gfx_set_decoder_scale 218 *---------------------------------------------------------------------------- 219 */ 220int 221gfx_set_decoder_scale(unsigned short srcw, unsigned short srch, 222 unsigned short dstw, unsigned short dsth) 223{ 224 int status = GFX_STATUS_UNSUPPORTED; 225 226#if GFX_DECODER_SAA7114 227 if (gfx_decoder_type == GFX_DECODER_SAA7114) 228 status = saa7114_set_decoder_scale(srcw, srch, dstw, dsth); 229#endif 230 return (status); 231} 232 233/*---------------------------------------------------------------------------- 234 * gfx_set_decoder_vbi_format 235 *---------------------------------------------------------------------------- 236 */ 237int 238gfx_set_decoder_vbi_format(int start, int end, int format) 239{ 240 int status = GFX_STATUS_UNSUPPORTED; 241 242#if GFX_DECODER_SAA7114 243 if (gfx_decoder_type == GFX_DECODER_SAA7114) 244 status = saa7114_set_decoder_vbi_format(start, end, format); 245#endif 246 return (status); 247} 248 249/*---------------------------------------------------------------------------- 250 * gfx_set_decoder_vbi_enable 251 *---------------------------------------------------------------------------- 252 */ 253int 254gfx_set_decoder_vbi_enable(int enable) 255{ 256 int status = GFX_STATUS_UNSUPPORTED; 257 258#if GFX_DECODER_SAA7114 259 if (gfx_decoder_type == GFX_DECODER_SAA7114) 260 status = saa7114_set_decoder_vbi_enable(enable); 261#endif 262 return (status); 263} 264 265/*---------------------------------------------------------------------------- 266 * gfx_set_decoder_vbi_upscale 267 *---------------------------------------------------------------------------- 268 */ 269int 270gfx_set_decoder_vbi_upscale(void) 271{ 272 int status = GFX_STATUS_UNSUPPORTED; 273 274#if GFX_DECODER_SAA7114 275 if (gfx_decoder_type == GFX_DECODER_SAA7114) 276 status = saa7114_set_decoder_vbi_upscale(); 277#endif 278 return (status); 279} 280 281/*---------------------------------------------------------------------------- 282 * gfx_set_decoder_TV_standard 283 *---------------------------------------------------------------------------- 284 */ 285int 286gfx_set_decoder_TV_standard(TVStandardType TVStandard) 287{ 288 int status = GFX_STATUS_UNSUPPORTED; 289 290#if GFX_DECODER_SAA7114 291 if (gfx_decoder_type == GFX_DECODER_SAA7114) 292 status = saa7114_set_decoder_TV_standard(TVStandard); 293#endif 294 return (status); 295} 296 297/*---------------------------------------------------------------------------- 298 * gfx_set_decoder_luminance_filter 299 *---------------------------------------------------------------------------- 300 */ 301int 302gfx_set_decoder_luminance_filter(unsigned char lufi) 303{ 304 int status = GFX_STATUS_UNSUPPORTED; 305 306#if GFX_DECODER_SAA7114 307 if (gfx_decoder_type == GFX_DECODER_SAA7114) 308 status = saa7114_set_decoder_luminance_filter(lufi); 309#endif 310 return (status); 311} 312 313/*---------------------------------------------------------------------------- 314 * gfx_decoder_software_reset 315 *---------------------------------------------------------------------------- 316 */ 317int 318gfx_decoder_software_reset(void) 319{ 320 int status = GFX_STATUS_UNSUPPORTED; 321 322#if GFX_DECODER_SAA7114 323 if (gfx_decoder_type == GFX_DECODER_SAA7114) 324 status = saa7114_decoder_software_reset(); 325#endif 326 return (status); 327} 328 329/*---------------------------------------------------------------------------- 330 * gfx_decoder_detect_macrovision 331 *---------------------------------------------------------------------------- 332 */ 333int 334gfx_decoder_detect_macrovision(void) 335{ 336 int status = GFX_STATUS_UNSUPPORTED; 337 338#if GFX_DECODER_SAA7114 339 if (gfx_decoder_type == GFX_DECODER_SAA7114) 340 status = saa7114_decoder_detect_macrovision(); 341#endif 342 return (status); 343} 344 345/*---------------------------------------------------------------------------- 346 * gfx_decoder_detect_video 347 *---------------------------------------------------------------------------- 348 */ 349int 350gfx_decoder_detect_video(void) 351{ 352 int status = GFX_STATUS_UNSUPPORTED; 353 354#if GFX_DECODER_SAA7114 355 if (gfx_decoder_type == GFX_DECODER_SAA7114) 356 status = saa7114_decoder_detect_video(); 357#endif 358 return (status); 359} 360 361/*************************************************************/ 362/* READ ROUTINES | INCLUDED FOR DIAGNOSTIC PURPOSES ONLY */ 363/*************************************************************/ 364 365#if GFX_READ_ROUTINES 366 367/*---------------------------------------------------------------------------- 368 * gfx_get_decoder_brightness 369 *---------------------------------------------------------------------------- 370 */ 371unsigned char 372gfx_get_decoder_brightness(void) 373{ 374 unsigned char brightness = 0; 375 376#if GFX_DECODER_SAA7114 377 if (gfx_decoder_type == GFX_DECODER_SAA7114) 378 brightness = saa7114_get_decoder_brightness(); 379#endif 380 return (brightness); 381} 382 383/*---------------------------------------------------------------------------- 384 * gfx_get_decoder_contrast 385 *---------------------------------------------------------------------------- 386 */ 387unsigned char 388gfx_get_decoder_contrast(void) 389{ 390 unsigned char contrast = 0; 391 392#if GFX_DECODER_SAA7114 393 if (gfx_decoder_type == GFX_DECODER_SAA7114) 394 contrast = saa7114_get_decoder_contrast(); 395#endif 396 return (contrast); 397} 398 399/*---------------------------------------------------------------------------- 400 * gfx_get_decoder_hue 401 *---------------------------------------------------------------------------- 402 */ 403char 404gfx_get_decoder_hue(void) 405{ 406 unsigned char hue = 0; 407 408#if GFX_DECODER_SAA7114 409 if (gfx_decoder_type == GFX_DECODER_SAA7114) 410 hue = saa7114_get_decoder_hue(); 411#endif 412 return ((char) hue); 413} 414 415/*---------------------------------------------------------------------------- 416 * gfx_get_decoder_saturation 417 *---------------------------------------------------------------------------- 418 */ 419unsigned char 420gfx_get_decoder_saturation(void) 421{ 422 unsigned char saturation = 0; 423 424#if GFX_DECODER_SAA7114 425 if (gfx_decoder_type == GFX_DECODER_SAA7114) 426 saturation = saa7114_get_decoder_saturation(); 427#endif 428 return (saturation); 429} 430 431/*---------------------------------------------------------------------------- 432 * gfx_get_decoder_input_offset 433 *---------------------------------------------------------------------------- 434 */ 435unsigned long 436gfx_get_decoder_input_offset() 437{ 438 unsigned long offset = 0; 439 440#if GFX_DECODER_SAA7114 441 if (gfx_decoder_type == GFX_DECODER_SAA7114) 442 offset = saa7114_get_decoder_input_offset(); 443#endif 444 return (offset); 445} 446 447/*---------------------------------------------------------------------------- 448 * gfx_get_decoder_input_size 449 *---------------------------------------------------------------------------- 450 */ 451unsigned long 452gfx_get_decoder_input_size() 453{ 454 unsigned long size = 0; 455 456#if GFX_DECODER_SAA7114 457 if (gfx_decoder_type == GFX_DECODER_SAA7114) 458 size = saa7114_get_decoder_input_size(); 459#endif 460 return (size); 461} 462 463/*---------------------------------------------------------------------------- 464 * gfx_get_decoder_output_size 465 *---------------------------------------------------------------------------- 466 */ 467unsigned long 468gfx_get_decoder_output_size() 469{ 470 unsigned long size = 0; 471 472#if GFX_DECODER_SAA7114 473 if (gfx_decoder_type == GFX_DECODER_SAA7114) 474 size = saa7114_get_decoder_output_size(); 475#endif 476 return (size); 477} 478 479/*---------------------------------------------------------------------------- 480 * gfx_get_decoder_vbi_format 481 *---------------------------------------------------------------------------- 482 */ 483int 484gfx_get_decoder_vbi_format(int line) 485{ 486 int format = 0; 487 488#if GFX_DECODER_SAA7114 489 if (gfx_decoder_type == GFX_DECODER_SAA7114) 490 format = saa7114_get_decoder_vbi_format(line); 491#endif 492 return (format); 493} 494 495#endif /* GFX_READ_ROUTINES */ 496 497#endif /* GFX_DECODER_DYNAMIC */ 498 499/* END OF FILE */ 500