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