1/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nsc/gfx/vip_1200.c,v 1.1 2002/12/10 15:12:27 alanh Exp $ */ 2/* 3 * $Workfile: vip_1200.c $ 4 * 5 * This file contains routines to control the SC1200 video input port (VIP) hardware. 6 * 7 * NSC_LIC_ALTERNATIVE_PREAMBLE 8 * 9 * Revision 1.0 10 * 11 * National Semiconductor Alternative GPL-BSD License 12 * 13 * National Semiconductor Corporation licenses this software 14 * ("Software"): 15 * 16 * Durango 17 * 18 * under one of the two following licenses, depending on how the 19 * Software is received by the Licensee. 20 * 21 * If this Software is received as part of the Linux Framebuffer or 22 * other GPL licensed software, then the GPL license designated 23 * NSC_LIC_GPL applies to this Software; in all other circumstances 24 * then the BSD-style license designated NSC_LIC_BSD shall apply. 25 * 26 * END_NSC_LIC_ALTERNATIVE_PREAMBLE */ 27 28/* NSC_LIC_BSD 29 * 30 * National Semiconductor Corporation Open Source License for Durango 31 * 32 * (BSD License with Export Notice) 33 * 34 * Copyright (c) 1999-2001 35 * National Semiconductor Corporation. 36 * All rights reserved. 37 * 38 * Redistribution and use in source and binary forms, with or without 39 * modification, are permitted provided that the following conditions 40 * are met: 41 * 42 * * Redistributions of source code must retain the above copyright 43 * notice, this list of conditions and the following disclaimer. 44 * 45 * * Redistributions in binary form must reproduce the above 46 * copyright notice, this list of conditions and the following 47 * disclaimer in the documentation and/or other materials provided 48 * with the distribution. 49 * 50 * * Neither the name of the National Semiconductor Corporation nor 51 * the names of its contributors may be used to endorse or promote 52 * products derived from this software without specific prior 53 * written permission. 54 * 55 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 56 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 57 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 58 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 59 * NATIONAL SEMICONDUCTOR CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY 60 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 61 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 62 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 63 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 64 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE, 65 * INTELLECTUAL PROPERTY INFRINGEMENT, OR OTHERWISE) ARISING IN ANY WAY 66 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 67 * OF SUCH DAMAGE. 68 * 69 * EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF 70 * YOUR JURISDICTION. It is licensee's responsibility to comply with 71 * any export regulations applicable in licensee's jurisdiction. Under 72 * CURRENT (2001) U.S. export regulations this software 73 * is eligible for export from the U.S. and can be downloaded by or 74 * otherwise exported or reexported worldwide EXCEPT to U.S. embargoed 75 * destinations which include Cuba, Iraq, Libya, North Korea, Iran, 76 * Syria, Sudan, Afghanistan and any other country to which the U.S. 77 * has embargoed goods and services. 78 * 79 * END_NSC_LIC_BSD */ 80 81/* NSC_LIC_GPL 82 * 83 * National Semiconductor Corporation Gnu General Public License for Durango 84 * 85 * (GPL License with Export Notice) 86 * 87 * Copyright (c) 1999-2001 88 * National Semiconductor Corporation. 89 * All rights reserved. 90 * 91 * Redistribution and use in source and binary forms, with or without 92 * modification, are permitted under the terms of the GNU General 93 * Public License as published by the Free Software Foundation; either 94 * version 2 of the License, or (at your option) any later version 95 * 96 * In addition to the terms of the GNU General Public License, neither 97 * the name of the National Semiconductor Corporation nor the names of 98 * its contributors may be used to endorse or promote products derived 99 * from this software without specific prior written permission. 100 * 101 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 102 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 103 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 104 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 105 * NATIONAL SEMICONDUCTOR CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY 106 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 107 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 108 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 109 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 110 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE, 111 * INTELLECTUAL PROPERTY INFRINGEMENT, OR OTHERWISE) ARISING IN ANY WAY 112 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 113 * OF SUCH DAMAGE. See the GNU General Public License for more details. 114 * 115 * EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF 116 * YOUR JURISDICTION. It is licensee's responsibility to comply with 117 * any export regulations applicable in licensee's jurisdiction. Under 118 * CURRENT (2001) U.S. export regulations this software 119 * is eligible for export from the U.S. and can be downloaded by or 120 * otherwise exported or reexported worldwide EXCEPT to U.S. embargoed 121 * destinations which include Cuba, Iraq, Libya, North Korea, Iran, 122 * Syria, Sudan, Afghanistan and any other country to which the U.S. 123 * has embargoed goods and services. 124 * 125 * You should have received a copy of the GNU General Public License 126 * along with this file; if not, write to the Free Software Foundation, 127 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 128 * 129 * END_NSC_LIC_GPL */ 130 131int sc1200_set_vip_enable(int enable); 132int sc1200_set_vip_capture_run_mode(int mode); 133int sc1200_set_vip_base(unsigned long even, unsigned long odd); 134int sc1200_set_vip_pitch(unsigned long pitch); 135int sc1200_set_vip_mode(int mode); 136int sc1200_set_vbi_enable(int enable); 137int sc1200_set_vbi_mode(int mode); 138int sc1200_set_vbi_base(unsigned long even, unsigned long odd); 139int sc1200_set_vbi_pitch(unsigned long pitch); 140int sc1200_set_vbi_direct(unsigned long even_lines, unsigned long odd_lines); 141int sc1200_set_vbi_interrupt(int enable); 142int sc1200_set_vip_bus_request_threshold_high(int enable); 143int sc1200_set_vip_last_line(int last_line); 144int sc1200_test_vip_odd_field(void); 145int sc1200_test_vip_bases_updated(void); 146int sc1200_test_vip_fifo_overflow(void); 147int sc1200_get_vip_line(void); 148 149/* READ ROUTINES IN GFX_VIP.C */ 150 151int sc1200_get_vip_enable(void); 152unsigned long sc1200_get_vip_base(int odd); 153unsigned long sc1200_get_vip_pitch(void); 154int sc1200_get_vip_mode(void); 155int sc1200_get_vbi_enable(void); 156int sc1200_get_vbi_mode(void); 157unsigned long sc1200_get_vbi_base(int odd); 158unsigned long sc1200_get_vbi_pitch(void); 159unsigned long sc1200_get_vbi_direct(int odd); 160int sc1200_get_vbi_interrupt(void); 161int sc1200_get_vip_bus_request_threshold_high(void); 162 163/*----------------------------------------------------------------------------- 164 * gfx_set_vip_enable 165 * 166 * This routine enables or disables the writes to memory from the video port. 167 *----------------------------------------------------------------------------- 168 */ 169#if GFX_VIP_DYNAMIC 170int 171sc1200_set_vip_enable(int enable) 172#else 173int 174gfx_set_vip_enable(int enable) 175#endif 176{ 177 unsigned long value; 178 179 value = READ_VIP32(SC1200_VIP_CONTROL); 180 if (enable) 181 value |= SC1200_VIP_DATA_CAPTURE_EN; 182 else 183 value &= ~SC1200_VIP_DATA_CAPTURE_EN; 184 WRITE_VIP32(SC1200_VIP_CONTROL, value); 185 return (0); 186} 187 188/*----------------------------------------------------------------------------- 189 * gfx_set_vip_capture_run_mode 190 * 191 * This routine selects VIP capture run mode. 192 *----------------------------------------------------------------------------- 193 */ 194#if GFX_VIP_DYNAMIC 195int 196sc1200_set_vip_capture_run_mode(int mode) 197#else 198int 199gfx_set_vip_capture_run_mode(int mode) 200#endif 201{ 202 unsigned long value; 203 204 value = READ_VIP32(SC1200_VIP_CONTROL); 205 value &= ~SC1200_CAPTURE_RUN_MODE_MASK; 206 switch (mode) { 207 case VIP_CAPTURE_STOP_LINE: 208 value |= SC1200_CAPTURE_RUN_MODE_STOP_LINE; 209 break; 210 case VIP_CAPTURE_STOP_FIELD: 211 value |= SC1200_CAPTURE_RUN_MODE_STOP_FIELD; 212 break; 213 case VIP_CAPTURE_START_FIELD: 214 value |= SC1200_CAPTURE_RUN_MODE_START; 215 break; 216 default: 217 return GFX_STATUS_BAD_PARAMETER; 218 } 219 WRITE_VIP32(SC1200_VIP_CONTROL, value); 220 return (0); 221} 222 223/*----------------------------------------------------------------------------- 224 * gfx_set_vip_base 225 * 226 * This routine sets the odd and even base address values for the VIP memory 227 * buffer. 228 *----------------------------------------------------------------------------- 229 */ 230#if GFX_VIP_DYNAMIC 231int 232sc1200_set_vip_base(unsigned long even, unsigned long odd) 233#else 234int 235gfx_set_vip_base(unsigned long even, unsigned long odd) 236#endif 237{ 238 /* TRUE OFFSET IS SPECIFIED, NEED TO SET BIT 23 FOR HARDWARE */ 239 240 if (even) 241 WRITE_VIP32(SC1200_VIP_EVEN_BASE, even + (unsigned long)gfx_phys_fbptr); 242 if (odd) 243 WRITE_VIP32(SC1200_VIP_ODD_BASE, odd + (unsigned long)gfx_phys_fbptr); 244 return (0); 245} 246 247/*----------------------------------------------------------------------------- 248 * gfx_set_vip_pitch 249 * 250 * This routine sets the number of bytes between scanlines for the VIP data. 251 *----------------------------------------------------------------------------- 252 */ 253#if GFX_VIP_DYNAMIC 254int 255sc1200_set_vip_pitch(unsigned long pitch) 256#else 257int 258gfx_set_vip_pitch(unsigned long pitch) 259#endif 260{ 261 WRITE_VIP32(SC1200_VIP_PITCH, pitch & SC1200_VIP_PITCH_MASK); 262 return (0); 263} 264 265/*----------------------------------------------------------------------------- 266 * gfx_set_vip_mode 267 * 268 * This routine sets the VIP operating mode. 269 *----------------------------------------------------------------------------- 270 */ 271#if GFX_VIP_DYNAMIC 272int 273sc1200_set_vip_mode(int mode) 274#else 275int 276gfx_set_vip_mode(int mode) 277#endif 278{ 279 unsigned long config; 280 281 config = READ_VIP32(SC1200_VIP_CONFIG); 282 config &= ~SC1200_VIP_MODE_MASK; 283 switch (mode) { 284 case VIP_MODE_C: 285 WRITE_VIP32(SC1200_VIP_CONFIG, config | SC1200_VIP_MODE_C); 286 break; 287 default: 288 return GFX_STATUS_BAD_PARAMETER; 289 } 290 return (0); 291} 292 293/*----------------------------------------------------------------------------- 294 * gfx_set_vbi_enable 295 * 296 * This routine enables or disables the VBI data capture. 297 *----------------------------------------------------------------------------- 298 */ 299#if GFX_VIP_DYNAMIC 300int 301sc1200_set_vbi_enable(int enable) 302#else 303int 304gfx_set_vbi_enable(int enable) 305#endif 306{ 307 unsigned long value; 308 309 value = READ_VIP32(SC1200_VIP_CONTROL); 310 if (enable) 311 value |= SC1200_VIP_VBI_CAPTURE_EN; 312 else 313 value &= ~SC1200_VIP_VBI_CAPTURE_EN; 314 WRITE_VIP32(SC1200_VIP_CONTROL, value); 315 return (0); 316} 317 318/*----------------------------------------------------------------------------- 319 * gfx_set_vbi_mode 320 * 321 * This routine sets the VBI data types captured to memory. 322 * It receives a mask of all enabled types. 323 *----------------------------------------------------------------------------- 324 */ 325#if GFX_VIP_DYNAMIC 326int 327sc1200_set_vbi_mode(int mode) 328#else 329int 330gfx_set_vbi_mode(int mode) 331#endif 332{ 333 unsigned long config; 334 335 config = READ_VIP32(SC1200_VIP_CONFIG); 336 config &= 337 ~(SC1200_VBI_ANCILLARY_TO_MEMORY | SC1200_VBI_TASK_A_TO_MEMORY | 338 SC1200_VBI_TASK_B_TO_MEMORY); 339 340 if (mode & VBI_ANCILLARY) 341 config |= SC1200_VBI_ANCILLARY_TO_MEMORY; 342 if (mode & VBI_TASK_A) 343 config |= SC1200_VBI_TASK_A_TO_MEMORY; 344 if (mode & VBI_TASK_B) 345 config |= SC1200_VBI_TASK_B_TO_MEMORY; 346 WRITE_VIP32(SC1200_VIP_CONFIG, config); 347 return (0); 348} 349 350/*----------------------------------------------------------------------------- 351 * gfx_set_vbi_base 352 * 353 * This routine sets the odd and even base address values for VBI capture. 354 * 355 * "even" and "odd" should contain 16-byte aligned physical addresses. 356 *----------------------------------------------------------------------------- 357 */ 358#if GFX_VIP_DYNAMIC 359int 360sc1200_set_vbi_base(unsigned long even, unsigned long odd) 361#else 362int 363gfx_set_vbi_base(unsigned long even, unsigned long odd) 364#endif 365{ 366 /* VIP HW REQUIRES THAT BASE ADDRESSES BE 16-BYTE ALIGNED */ 367 368 if (even) 369 WRITE_VIP32(SC1200_VBI_EVEN_BASE, even & ~0xf); 370 if (odd) 371 WRITE_VIP32(SC1200_VBI_ODD_BASE, odd & ~0xf); 372 373 return (0); 374} 375 376/*----------------------------------------------------------------------------- 377 * gfx_set_vbi_pitch 378 * 379 * This routine sets the number of bytes between scanlines for VBI capture. 380 *----------------------------------------------------------------------------- 381 */ 382#if GFX_VIP_DYNAMIC 383int 384sc1200_set_vbi_pitch(unsigned long pitch) 385#else 386int 387gfx_set_vbi_pitch(unsigned long pitch) 388#endif 389{ 390 WRITE_VIP32(SC1200_VBI_PITCH, pitch & SC1200_VBI_PITCH_MASK); 391 return (0); 392} 393 394/*----------------------------------------------------------------------------- 395 * gfx_set_vbi_direct 396 * 397 * This routine sets the VBI lines to be passed to the Direct VIP. 398 *----------------------------------------------------------------------------- 399 */ 400#if GFX_VIP_DYNAMIC 401int 402sc1200_set_vbi_direct(unsigned long even_lines, unsigned long odd_lines) 403#else 404int 405gfx_set_vbi_direct(unsigned long even_lines, unsigned long odd_lines) 406#endif 407{ 408 WRITE_VIP32(SC1200_EVEN_DIRECT_VBI_LINE_ENABLE, 409 even_lines & SC1200_DIRECT_VBI_LINE_ENABLE_MASK); 410 WRITE_VIP32(SC1200_ODD_DIRECT_VBI_LINE_ENABLE, 411 odd_lines & SC1200_DIRECT_VBI_LINE_ENABLE_MASK); 412 return (0); 413} 414 415/*----------------------------------------------------------------------------- 416 * gfx_set_vbi_interrupt 417 * 418 * This routine enables or disables the VBI field interrupt. 419 *----------------------------------------------------------------------------- 420 */ 421#if GFX_VIP_DYNAMIC 422int 423sc1200_set_vbi_interrupt(int enable) 424#else 425int 426gfx_set_vbi_interrupt(int enable) 427#endif 428{ 429 unsigned long value; 430 431 value = READ_VIP32(SC1200_VIP_CONTROL); 432 if (enable) 433 value |= SC1200_VIP_VBI_FIELD_INTERRUPT_EN; 434 else 435 value &= ~SC1200_VIP_VBI_FIELD_INTERRUPT_EN; 436 WRITE_VIP32(SC1200_VIP_CONTROL, value); 437 return (0); 438} 439 440/*----------------------------------------------------------------------------- 441 * gfx_set_vip_bus_request_threshold_high 442 * 443 * This routine sets the VIP FIFO bus request threshold. 444 * If enable is TRUE, VIP FIFO will be set to issue a bus request when it filled with 64 bytes. 445 * If enable is FALSE, VIP FIFO will be set to issue a bus request when it filled with 32 bytes. 446 *----------------------------------------------------------------------------- 447 */ 448#if GFX_VIP_DYNAMIC 449int 450sc1200_set_vip_bus_request_threshold_high(int enable) 451#else 452int 453gfx_set_vip_bus_request_threshold_high(int enable) 454#endif 455{ 456 unsigned long value; 457 458 value = READ_VIP32(SC1200_VIP_CONFIG); 459 if (enable) 460 value &= ~SC1200_VIP_BUS_REQUEST_THRESHOLD; 461 else 462 value |= SC1200_VIP_BUS_REQUEST_THRESHOLD; 463 WRITE_VIP32(SC1200_VIP_CONFIG, value); 464 return (0); 465} 466 467/*----------------------------------------------------------------------------- 468 * gfx_set_vip_last_line 469 * 470 * This routine sets the maximum number of lines captured in each field. 471 *----------------------------------------------------------------------------- 472 */ 473#if GFX_VIP_DYNAMIC 474int 475sc1200_set_vip_last_line(int last_line) 476#else 477int 478gfx_set_vip_last_line(int last_line) 479#endif 480{ 481 unsigned long value; 482 483 /* This feature is implemented in Rev C1 */ 484 if (gfx_chip_revision < SC1200_REV_C1) 485 return (GFX_STATUS_OK); 486 487 value = READ_VIP32(SC1200_VIP_LINE_TARGET); 488 value &= ~SC1200_VIP_LAST_LINE_MASK; 489 value |= ((last_line & 0x3FF) << 16); 490 WRITE_VIP32(SC1200_VIP_LINE_TARGET, value); 491 return (GFX_STATUS_OK); 492} 493 494/*----------------------------------------------------------------------------- 495 * gfx_test_vip_odd_field 496 * 497 * This routine returns 1 if the current VIP field is odd. Otherwise returns 0. 498 *----------------------------------------------------------------------------- 499 */ 500#if GFX_VIP_DYNAMIC 501int 502sc1200_test_vip_odd_field(void) 503#else 504int 505gfx_test_vip_odd_field(void) 506#endif 507{ 508 if (READ_VIP32(SC1200_VIP_STATUS) & SC1200_VIP_CURRENT_FIELD_ODD) 509 return (1); 510 else 511 return (0); 512} 513 514/*----------------------------------------------------------------------------- 515 * gfx_test_vip_bases_updated 516 * 517 * This routine returns 1 if all of the VIP base registers have been updated, 518 * i.e. there is no base register which has been written with a new address, 519 * that VIP has not already captured or started capturing into the new address. 520 *----------------------------------------------------------------------------- 521 */ 522#if GFX_VIP_DYNAMIC 523int 524sc1200_test_vip_bases_updated(void) 525#else 526int 527gfx_test_vip_bases_updated(void) 528#endif 529{ 530 if (READ_VIP32(SC1200_VIP_STATUS) & SC1200_VIP_BASE_NOT_UPDATED) 531 return (0); 532 else 533 return (1); 534} 535 536/*----------------------------------------------------------------------------- 537 * gfx_test_vip_fifo_overflow 538 * 539 * This routine returns 1 if an overflow occurred on the FIFO between the VIP 540 * and the fast X-bus, 0 otherwise. 541 * If an overflow occurred, the overflow status indication is reset. 542 *----------------------------------------------------------------------------- 543 */ 544#if GFX_VIP_DYNAMIC 545int 546sc1200_test_vip_fifo_overflow(void) 547#else 548int 549gfx_test_vip_fifo_overflow(void) 550#endif 551{ 552 if (READ_VIP32(SC1200_VIP_STATUS) & SC1200_VIP_FIFO_OVERFLOW) { 553 /* Bits in vip status register are either read only or reset by writing 1 */ 554 WRITE_VIP32(SC1200_VIP_STATUS, SC1200_VIP_FIFO_OVERFLOW); 555 return (1); 556 } else { 557 return (0); 558 } 559} 560 561/*----------------------------------------------------------------------------- 562 * gfx_get_vip_line 563 * 564 * This routine returns the number of the current video line being 565 * received by the VIP interface. 566 *----------------------------------------------------------------------------- 567 */ 568#if GFX_VIP_DYNAMIC 569int 570sc1200_get_vip_line(void) 571#else 572int 573gfx_get_vip_line(void) 574#endif 575{ 576 return (int)(READ_VIP32(SC1200_VIP_CURRENT_LINE) & 577 SC1200_VIP_CURRENT_LINE_MASK); 578} 579 580/*----------------------------------------------------------------------------- 581 * gfx_get_vip_base 582 *----------------------------------------------------------------------------- 583 */ 584#if GFX_VIP_DYNAMIC 585unsigned long 586sc1200_get_vip_base(int odd) 587#else 588unsigned long 589gfx_get_vip_base(int odd) 590#endif 591{ 592 /* MASK BIT 23 AND ABOVE TO MAKE IT A TRUE OFFSET */ 593 594 if (odd) 595 return (READ_VIP32(SC1200_VIP_ODD_BASE)); 596 return (READ_VIP32(SC1200_VIP_EVEN_BASE)); 597} 598 599/*----------------------------------------------------------------------------- 600 * gfx_get_vbi_pitch 601 *----------------------------------------------------------------------------- 602 */ 603#if GFX_VIP_DYNAMIC 604unsigned long 605sc1200_get_vbi_pitch(void) 606#else 607unsigned long 608gfx_get_vbi_pitch(void) 609#endif 610{ 611 return (READ_VIP32(SC1200_VBI_PITCH) & SC1200_VBI_PITCH_MASK); 612} 613 614/*************************************************************/ 615/* READ ROUTINES | INCLUDED FOR DIAGNOSTIC PURPOSES ONLY */ 616/*************************************************************/ 617 618#if GFX_READ_ROUTINES 619 620/*----------------------------------------------------------------------------- 621 * gfx_get_vip_enable 622 *----------------------------------------------------------------------------- 623 */ 624#if GFX_VIP_DYNAMIC 625int 626sc1200_get_vip_enable(void) 627#else 628int 629gfx_get_vip_enable(void) 630#endif 631{ 632 if (READ_VIP32(SC1200_VIP_CONTROL) & SC1200_VIP_DATA_CAPTURE_EN) 633 return (1); 634 return (0); 635} 636 637/*----------------------------------------------------------------------------- 638 * gfx_get_vip_pitch 639 *----------------------------------------------------------------------------- 640 */ 641#if GFX_VIP_DYNAMIC 642unsigned long 643sc1200_get_vip_pitch(void) 644#else 645unsigned long 646gfx_get_vip_pitch(void) 647#endif 648{ 649 return (READ_VIP32(SC1200_VIP_PITCH) & SC1200_VIP_PITCH_MASK); 650} 651 652/*----------------------------------------------------------------------------- 653 * gfx_get_vip_mode 654 *----------------------------------------------------------------------------- 655 */ 656#if GFX_VIP_DYNAMIC 657int 658sc1200_get_vip_mode(void) 659#else 660int 661gfx_get_vip_mode(void) 662#endif 663{ 664 switch (READ_VIP32(SC1200_VIP_CONFIG) & SC1200_VIP_MODE_MASK) { 665 case SC1200_VIP_MODE_C: 666 return VIP_MODE_C; 667 default: 668 return (0); 669 } 670} 671 672/*----------------------------------------------------------------------------- 673 * gfx_get_vbi_enable 674 *----------------------------------------------------------------------------- 675 */ 676#if GFX_VIP_DYNAMIC 677int 678sc1200_get_vbi_enable(void) 679#else 680int 681gfx_get_vbi_enable(void) 682#endif 683{ 684 if (READ_VIP32(SC1200_VIP_CONTROL) & SC1200_VIP_VBI_CAPTURE_EN) 685 return (1); 686 return (0); 687} 688 689/*----------------------------------------------------------------------------- 690 * gfx_get_vbi_mode 691 *----------------------------------------------------------------------------- 692 */ 693#if GFX_VIP_DYNAMIC 694int 695sc1200_get_vbi_mode(void) 696#else 697int 698gfx_get_vbi_mode(void) 699#endif 700{ 701 int config; 702 int mode = 0; 703 704 config = 705 (int)(READ_VIP32(SC1200_VIP_CONFIG) & 706 (SC1200_VBI_ANCILLARY_TO_MEMORY | SC1200_VBI_TASK_A_TO_MEMORY | 707 SC1200_VBI_TASK_B_TO_MEMORY)); 708 if (config & SC1200_VBI_ANCILLARY_TO_MEMORY) 709 mode |= VBI_ANCILLARY; 710 if (config & SC1200_VBI_TASK_A_TO_MEMORY) 711 mode |= VBI_TASK_A; 712 if (config & SC1200_VBI_TASK_B_TO_MEMORY) 713 mode |= VBI_TASK_B; 714 return mode; 715} 716 717/*----------------------------------------------------------------------------- 718 * gfx_get_vbi_base 719 *----------------------------------------------------------------------------- 720 */ 721#if GFX_VIP_DYNAMIC 722unsigned long 723sc1200_get_vbi_base(int odd) 724#else 725unsigned long 726gfx_get_vbi_base(int odd) 727#endif 728{ 729 /* MASK BIT 23 AND ABOVE TO MAKE IT A TRUE OFFSET */ 730 731 if (odd) 732 return (READ_VIP32(SC1200_VBI_ODD_BASE)); 733 return (READ_VIP32(SC1200_VBI_EVEN_BASE)); 734} 735 736/*----------------------------------------------------------------------------- 737 * gfx_get_vbi_direct 738 *----------------------------------------------------------------------------- 739 */ 740#if GFX_VIP_DYNAMIC 741unsigned long 742sc1200_get_vbi_direct(int odd) 743#else 744unsigned long 745gfx_get_vbi_direct(int odd) 746#endif 747{ 748 /* MASK BIT 23 AND ABOVE TO MAKE IT A TRUE OFFSET */ 749 750 if (odd) 751 return (READ_VIP32(SC1200_ODD_DIRECT_VBI_LINE_ENABLE) & 752 SC1200_DIRECT_VBI_LINE_ENABLE_MASK); 753 return (READ_VIP32(SC1200_EVEN_DIRECT_VBI_LINE_ENABLE) & 754 SC1200_DIRECT_VBI_LINE_ENABLE_MASK); 755} 756 757/*----------------------------------------------------------------------------- 758 * gfx_get_vbi_interrupt 759 *----------------------------------------------------------------------------- 760 */ 761#if GFX_VIP_DYNAMIC 762int 763sc1200_get_vbi_interrupt(void) 764#else 765int 766gfx_get_vbi_interrupt(void) 767#endif 768{ 769 if (READ_VIP32(SC1200_VIP_CONTROL) & SC1200_VIP_VBI_FIELD_INTERRUPT_EN) 770 return (1); 771 return (0); 772} 773 774/*----------------------------------------------------------------------------- 775 * gfx_get_vip_bus_request_threshold_high 776 *----------------------------------------------------------------------------- 777 */ 778#if GFX_VIP_DYNAMIC 779int 780sc1200_get_vip_bus_request_threshold_high(void) 781#else 782int 783gfx_get_vip_bus_request_threshold_high(void) 784#endif 785{ 786 if (READ_VIP32(SC1200_VIP_CONFIG) & SC1200_VIP_BUS_REQUEST_THRESHOLD) 787 return (1); 788 return (0); 789} 790 791#endif /* GFX_READ_ROUTINES */ 792 793/* END OF FILE */ 794