1/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nsc/gfx/gfx_dcdr.c,v 1.1 2002/12/10 15:12:25 alanh Exp $ */ 2/* 3 * $Workfile: gfx_dcdr.c $ 4 * 5 * This file contains routines to control the video decoder. 6 * 7 * gfx_set_decoder_defaults 8 * gfx_set_decoder_analog_input 9 * gfx_set_decoder_brightness 10 * gfx_set_decoder_contrast 11 * gfx_set_decoder_luminance_filter 12 * gfx_set_decoder_hue 13 * gfx_set_decoder_saturation 14 * gfx_set_decoder_input_offset 15 * gfx_set_decoder_input_size 16 * gfx_set_decoder_output_size 17 * gfx_set_decoder_scale 18 * gfx_set_decoder_TV_standard 19 * gfx_set_decoder_vbi_enable 20 * gfx_set_decoder_vbi_format 21 * gfx_set_decoder_vbi_upscale 22 * gfx_decoder_software_reset 23 * gfx_decoder_detect_macrovision 24 * gfx_decoder_detect_video 25 * 26 * And the following routines if GFX_READ_ROUTINES is set: 27 * 28 * gfx_get_decoder_brightness 29 * gfx_get_decoder_contrast 30 * gfx_get_decoder_hue 31 * gfx_get_decoder_saturation 32 * gfx_get_decoder_input_offset 33 * gfx_get_decoder_input_size 34 * gfx_get_decoder_output_size 35 * gfx_get_decoder_vbi_format 36 * 37 * NSC_LIC_ALTERNATIVE_PREAMBLE 38 * 39 * Revision 1.0 40 * 41 * National Semiconductor Alternative GPL-BSD License 42 * 43 * National Semiconductor Corporation licenses this software 44 * ("Software"): 45 * 46 * Durango 47 * 48 * under one of the two following licenses, depending on how the 49 * Software is received by the Licensee. 50 * 51 * If this Software is received as part of the Linux Framebuffer or 52 * other GPL licensed software, then the GPL license designated 53 * NSC_LIC_GPL applies to this Software; in all other circumstances 54 * then the BSD-style license designated NSC_LIC_BSD shall apply. 55 * 56 * END_NSC_LIC_ALTERNATIVE_PREAMBLE */ 57 58/* NSC_LIC_BSD 59 * 60 * National Semiconductor Corporation Open Source License for Durango 61 * 62 * (BSD License with Export Notice) 63 * 64 * Copyright (c) 1999-2001 65 * National Semiconductor Corporation. 66 * All rights reserved. 67 * 68 * Redistribution and use in source and binary forms, with or without 69 * modification, are permitted provided that the following conditions 70 * are met: 71 * 72 * * Redistributions of source code must retain the above copyright 73 * notice, this list of conditions and the following disclaimer. 74 * 75 * * Redistributions in binary form must reproduce the above 76 * copyright notice, this list of conditions and the following 77 * disclaimer in the documentation and/or other materials provided 78 * with the distribution. 79 * 80 * * Neither the name of the National Semiconductor Corporation nor 81 * the names of its contributors may be used to endorse or promote 82 * products derived from this software without specific prior 83 * written permission. 84 * 85 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 86 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 87 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 88 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 89 * NATIONAL SEMICONDUCTOR CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY 90 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 91 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 92 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 93 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 94 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE, 95 * INTELLECTUAL PROPERTY INFRINGEMENT, OR OTHERWISE) ARISING IN ANY WAY 96 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 97 * OF SUCH DAMAGE. 98 * 99 * EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF 100 * YOUR JURISDICTION. It is licensee's responsibility to comply with 101 * any export regulations applicable in licensee's jurisdiction. Under 102 * CURRENT (2001) U.S. export regulations this software 103 * is eligible for export from the U.S. and can be downloaded by or 104 * otherwise exported or reexported worldwide EXCEPT to U.S. embargoed 105 * destinations which include Cuba, Iraq, Libya, North Korea, Iran, 106 * Syria, Sudan, Afghanistan and any other country to which the U.S. 107 * has embargoed goods and services. 108 * 109 * END_NSC_LIC_BSD */ 110 111/* NSC_LIC_GPL 112 * 113 * National Semiconductor Corporation Gnu General Public License for Durango 114 * 115 * (GPL License with Export Notice) 116 * 117 * Copyright (c) 1999-2001 118 * National Semiconductor Corporation. 119 * All rights reserved. 120 * 121 * Redistribution and use in source and binary forms, with or without 122 * modification, are permitted under the terms of the GNU General 123 * Public License as published by the Free Software Foundation; either 124 * version 2 of the License, or (at your option) any later version 125 * 126 * In addition to the terms of the GNU General Public License, neither 127 * the name of the National Semiconductor Corporation nor the names of 128 * its contributors may be used to endorse or promote products derived 129 * from this software without specific prior written permission. 130 * 131 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 132 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 133 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 134 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 135 * NATIONAL SEMICONDUCTOR CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY 136 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 137 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 138 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 139 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 140 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE, 141 * INTELLECTUAL PROPERTY INFRINGEMENT, OR OTHERWISE) ARISING IN ANY WAY 142 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 143 * OF SUCH DAMAGE. See the GNU General Public License for more details. 144 * 145 * EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF 146 * YOUR JURISDICTION. It is licensee's responsibility to comply with 147 * any export regulations applicable in licensee's jurisdiction. Under 148 * CURRENT (2001) U.S. export regulations this software 149 * is eligible for export from the U.S. and can be downloaded by or 150 * otherwise exported or reexported worldwide EXCEPT to U.S. embargoed 151 * destinations which include Cuba, Iraq, Libya, North Korea, Iran, 152 * Syria, Sudan, Afghanistan and any other country to which the U.S. 153 * has embargoed goods and services. 154 * 155 * You should have received a copy of the GNU General Public License 156 * along with this file; if not, write to the Free Software Foundation, 157 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 158 * 159 * END_NSC_LIC_GPL */ 160 161/* INCLUDE SUPPORT FOR PHILIPS SAA7114 DECODER, IF SPECIFIED */ 162 163#if GFX_DECODER_SAA7114 164#include "saa7114.c" 165#endif 166 167/* WRAPPERS IF DYNAMIC SELECTION */ 168/* Extra layer to call various decoders. Currently only the Pillips */ 169/* decoder is supported, but still organized to easily expand later. */ 170 171#if GFX_DECODER_DYNAMIC 172 173/*----------------------------------------------------------------------------- 174 * gfx_set_decoder_defaults 175 *----------------------------------------------------------------------------- 176 */ 177int 178gfx_set_decoder_defaults(void) 179{ 180 int status = GFX_STATUS_UNSUPPORTED; 181 182# if GFX_DECODER_SAA7114 183 if (gfx_decoder_type == GFX_DECODER_SAA7114) 184 status = saa7114_set_decoder_defaults(); 185# endif 186 return (status); 187} 188 189/*----------------------------------------------------------------------------- 190 * gfx_set_decoder_analog_input 191 *----------------------------------------------------------------------------- 192 */ 193int 194gfx_set_decoder_analog_input(unsigned char input) 195{ 196 int status = GFX_STATUS_UNSUPPORTED; 197 198# if GFX_DECODER_SAA7114 199 if (gfx_decoder_type == GFX_DECODER_SAA7114) 200 status = saa7114_set_decoder_analog_input(input); 201# endif 202 return (status); 203} 204 205/*----------------------------------------------------------------------------- 206 * gfx_set_decoder_brightness 207 *----------------------------------------------------------------------------- 208 */ 209int 210gfx_set_decoder_brightness(unsigned char brightness) 211{ 212 int status = GFX_STATUS_UNSUPPORTED; 213 214# if GFX_DECODER_SAA7114 215 if (gfx_decoder_type == GFX_DECODER_SAA7114) 216 status = saa7114_set_decoder_brightness(brightness); 217# endif 218 return (status); 219} 220 221/*----------------------------------------------------------------------------- 222 * gfx_set_decoder_contrast 223 *----------------------------------------------------------------------------- 224 */ 225int 226gfx_set_decoder_contrast(unsigned char contrast) 227{ 228 int status = GFX_STATUS_UNSUPPORTED; 229 230# if GFX_DECODER_SAA7114 231 if (gfx_decoder_type == GFX_DECODER_SAA7114) 232 status = saa7114_set_decoder_contrast(contrast); 233# endif 234 return (status); 235} 236 237/*----------------------------------------------------------------------------- 238 * gfx_set_decoder_hue 239 *----------------------------------------------------------------------------- 240 */ 241int 242gfx_set_decoder_hue(char hue) 243{ 244 int status = GFX_STATUS_UNSUPPORTED; 245 246# if GFX_DECODER_SAA7114 247 if (gfx_decoder_type == GFX_DECODER_SAA7114) 248 status = saa7114_set_decoder_hue(hue); 249# endif 250 return (status); 251} 252 253/*----------------------------------------------------------------------------- 254 * gfx_set_decoder_saturation 255 *----------------------------------------------------------------------------- 256 */ 257int 258gfx_set_decoder_saturation(unsigned char saturation) 259{ 260 int status = GFX_STATUS_UNSUPPORTED; 261 262# if GFX_DECODER_SAA7114 263 if (gfx_decoder_type == GFX_DECODER_SAA7114) 264 status = saa7114_set_decoder_saturation(saturation); 265# endif 266 return (status); 267} 268 269/*----------------------------------------------------------------------------- 270 * gfx_set_decoder_input_offset 271 *----------------------------------------------------------------------------- 272 */ 273int 274gfx_set_decoder_input_offset(unsigned short x, unsigned short y) 275{ 276 int status = GFX_STATUS_UNSUPPORTED; 277 278# if GFX_DECODER_SAA7114 279 if (gfx_decoder_type == GFX_DECODER_SAA7114) 280 status = saa7114_set_decoder_input_offset(x, y); 281# endif 282 return (status); 283} 284 285/*----------------------------------------------------------------------------- 286 * gfx_set_decoder_input_size 287 *----------------------------------------------------------------------------- 288 */ 289int 290gfx_set_decoder_input_size(unsigned short width, unsigned short height) 291{ 292 int status = GFX_STATUS_UNSUPPORTED; 293 294# if GFX_DECODER_SAA7114 295 if (gfx_decoder_type == GFX_DECODER_SAA7114) 296 status = saa7114_set_decoder_input_size(width, height); 297# endif 298 return (status); 299} 300 301/*----------------------------------------------------------------------------- 302 * gfx_set_decoder_output_size 303 *----------------------------------------------------------------------------- 304 */ 305int 306gfx_set_decoder_output_size(unsigned short width, unsigned short height) 307{ 308 int status = GFX_STATUS_UNSUPPORTED; 309 310# if GFX_DECODER_SAA7114 311 if (gfx_decoder_type == GFX_DECODER_SAA7114) 312 status = saa7114_set_decoder_output_size(width, height); 313# endif 314 return (status); 315} 316 317/*----------------------------------------------------------------------------- 318 * gfx_set_decoder_scale 319 *----------------------------------------------------------------------------- 320 */ 321int 322gfx_set_decoder_scale(unsigned short srcw, unsigned short srch, 323 unsigned short dstw, unsigned short dsth) 324{ 325 int status = GFX_STATUS_UNSUPPORTED; 326 327# if GFX_DECODER_SAA7114 328 if (gfx_decoder_type == GFX_DECODER_SAA7114) 329 status = saa7114_set_decoder_scale(srcw, srch, dstw, dsth); 330# endif 331 return (status); 332} 333 334/*----------------------------------------------------------------------------- 335 * gfx_set_decoder_vbi_format 336 *----------------------------------------------------------------------------- 337 */ 338int 339gfx_set_decoder_vbi_format(int start, int end, int format) 340{ 341 int status = GFX_STATUS_UNSUPPORTED; 342 343# if GFX_DECODER_SAA7114 344 if (gfx_decoder_type == GFX_DECODER_SAA7114) 345 status = saa7114_set_decoder_vbi_format(start, end, format); 346# endif 347 return (status); 348} 349 350/*----------------------------------------------------------------------------- 351 * gfx_set_decoder_vbi_enable 352 *----------------------------------------------------------------------------- 353 */ 354int 355gfx_set_decoder_vbi_enable(int enable) 356{ 357 int status = GFX_STATUS_UNSUPPORTED; 358 359# if GFX_DECODER_SAA7114 360 if (gfx_decoder_type == GFX_DECODER_SAA7114) 361 status = saa7114_set_decoder_vbi_enable(enable); 362# endif 363 return (status); 364} 365 366/*----------------------------------------------------------------------------- 367 * gfx_set_decoder_vbi_upscale 368 *----------------------------------------------------------------------------- 369 */ 370int 371gfx_set_decoder_vbi_upscale(void) 372{ 373 int status = GFX_STATUS_UNSUPPORTED; 374 375# if GFX_DECODER_SAA7114 376 if (gfx_decoder_type == GFX_DECODER_SAA7114) 377 status = saa7114_set_decoder_vbi_upscale(); 378# endif 379 return (status); 380} 381 382/*----------------------------------------------------------------------------- 383 * gfx_set_decoder_TV_standard 384 *----------------------------------------------------------------------------- 385 */ 386int 387gfx_set_decoder_TV_standard(TVStandardType TVStandard) 388{ 389 int status = GFX_STATUS_UNSUPPORTED; 390 391# if GFX_DECODER_SAA7114 392 if (gfx_decoder_type == GFX_DECODER_SAA7114) 393 status = saa7114_set_decoder_TV_standard(TVStandard); 394# endif 395 return (status); 396} 397 398/*----------------------------------------------------------------------------- 399 * gfx_set_decoder_luminance_filter 400 *----------------------------------------------------------------------------- 401 */ 402int 403gfx_set_decoder_luminance_filter(unsigned char lufi) 404{ 405 int status = GFX_STATUS_UNSUPPORTED; 406 407# if GFX_DECODER_SAA7114 408 if (gfx_decoder_type == GFX_DECODER_SAA7114) 409 status = saa7114_set_decoder_luminance_filter(lufi); 410# endif 411 return (status); 412} 413 414/*----------------------------------------------------------------------------- 415 * gfx_decoder_software_reset 416 *----------------------------------------------------------------------------- 417 */ 418int 419gfx_decoder_software_reset(void) 420{ 421 int status = GFX_STATUS_UNSUPPORTED; 422 423# if GFX_DECODER_SAA7114 424 if (gfx_decoder_type == GFX_DECODER_SAA7114) 425 status = saa7114_decoder_software_reset(); 426# endif 427 return (status); 428} 429 430/*----------------------------------------------------------------------------- 431 * gfx_decoder_detect_macrovision 432 *----------------------------------------------------------------------------- 433 */ 434int 435gfx_decoder_detect_macrovision(void) 436{ 437 int status = GFX_STATUS_UNSUPPORTED; 438 439# if GFX_DECODER_SAA7114 440 if (gfx_decoder_type == GFX_DECODER_SAA7114) 441 status = saa7114_decoder_detect_macrovision(); 442# endif 443 return (status); 444} 445 446/*----------------------------------------------------------------------------- 447 * gfx_decoder_detect_video 448 *----------------------------------------------------------------------------- 449 */ 450int 451gfx_decoder_detect_video(void) 452{ 453 int status = GFX_STATUS_UNSUPPORTED; 454 455# if GFX_DECODER_SAA7114 456 if (gfx_decoder_type == GFX_DECODER_SAA7114) 457 status = saa7114_decoder_detect_video(); 458# endif 459 return (status); 460} 461 462/*************************************************************/ 463/* READ ROUTINES | INCLUDED FOR DIAGNOSTIC PURPOSES ONLY */ 464/*************************************************************/ 465 466#if GFX_READ_ROUTINES 467 468/*----------------------------------------------------------------------------- 469 * gfx_get_decoder_brightness 470 *----------------------------------------------------------------------------- 471 */ 472unsigned char 473gfx_get_decoder_brightness(void) 474{ 475 unsigned char brightness = 0; 476 477# if GFX_DECODER_SAA7114 478 if (gfx_decoder_type == GFX_DECODER_SAA7114) 479 brightness = saa7114_get_decoder_brightness(); 480# endif 481 return (brightness); 482} 483 484/*----------------------------------------------------------------------------- 485 * gfx_get_decoder_contrast 486 *----------------------------------------------------------------------------- 487 */ 488unsigned char 489gfx_get_decoder_contrast(void) 490{ 491 unsigned char contrast = 0; 492 493# if GFX_DECODER_SAA7114 494 if (gfx_decoder_type == GFX_DECODER_SAA7114) 495 contrast = saa7114_get_decoder_contrast(); 496# endif 497 return (contrast); 498} 499 500/*----------------------------------------------------------------------------- 501 * gfx_get_decoder_hue 502 *----------------------------------------------------------------------------- 503 */ 504char 505gfx_get_decoder_hue(void) 506{ 507 unsigned char hue = 0; 508 509# if GFX_DECODER_SAA7114 510 if (gfx_decoder_type == GFX_DECODER_SAA7114) 511 hue = saa7114_get_decoder_hue(); 512# endif 513 return ((char)hue); 514} 515 516/*----------------------------------------------------------------------------- 517 * gfx_get_decoder_saturation 518 *----------------------------------------------------------------------------- 519 */ 520unsigned char 521gfx_get_decoder_saturation(void) 522{ 523 unsigned char saturation = 0; 524 525# if GFX_DECODER_SAA7114 526 if (gfx_decoder_type == GFX_DECODER_SAA7114) 527 saturation = saa7114_get_decoder_saturation(); 528# endif 529 return (saturation); 530} 531 532/*----------------------------------------------------------------------------- 533 * gfx_get_decoder_input_offset 534 *----------------------------------------------------------------------------- 535 */ 536unsigned long 537gfx_get_decoder_input_offset() 538{ 539 unsigned long offset = 0; 540 541# if GFX_DECODER_SAA7114 542 if (gfx_decoder_type == GFX_DECODER_SAA7114) 543 offset = saa7114_get_decoder_input_offset(); 544# endif 545 return (offset); 546} 547 548/*----------------------------------------------------------------------------- 549 * gfx_get_decoder_input_size 550 *----------------------------------------------------------------------------- 551 */ 552unsigned long 553gfx_get_decoder_input_size() 554{ 555 unsigned long size = 0; 556 557# if GFX_DECODER_SAA7114 558 if (gfx_decoder_type == GFX_DECODER_SAA7114) 559 size = saa7114_get_decoder_input_size(); 560# endif 561 return (size); 562} 563 564/*----------------------------------------------------------------------------- 565 * gfx_get_decoder_output_size 566 *----------------------------------------------------------------------------- 567 */ 568unsigned long 569gfx_get_decoder_output_size() 570{ 571 unsigned long size = 0; 572 573# if GFX_DECODER_SAA7114 574 if (gfx_decoder_type == GFX_DECODER_SAA7114) 575 size = saa7114_get_decoder_output_size(); 576# endif 577 return (size); 578} 579 580/*----------------------------------------------------------------------------- 581 * gfx_get_decoder_vbi_format 582 *----------------------------------------------------------------------------- 583 */ 584int 585gfx_get_decoder_vbi_format(int line) 586{ 587 int format = 0; 588 589# if GFX_DECODER_SAA7114 590 if (gfx_decoder_type == GFX_DECODER_SAA7114) 591 format = saa7114_get_decoder_vbi_format(line); 592# endif 593 return (format); 594} 595 596#endif /* GFX_READ_ROUTINES */ 597 598#endif /* GFX_DECODER_DYNAMIC */ 599 600/* END OF FILE */ 601