1/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nsc/gfx/tv_geode.c,v 1.1 2002/12/10 15:12:27 alanh Exp $ */
2/*-----------------------------------------------------------------------------
3 * TV_GEODE.C
4 *
5 * Version 1.20 - February 9, 2000
6 *
7 * This file contains routines to program the TV encoder when it is
8 * integrated onto a Geode processor.
9 *
10 * History:
11 *    Initial version ported from code by Ilia Stolov.
12 *    Versions 0.1 through 1.20 by Brian Falardeau.
13 *
14 * Copyright (c) 1999-2000 National Semiconductor.
15 *-----------------------------------------------------------------------------
16 */
17
18/*-----------------------------------------------------------------------------
19 * gfx_set_tv_defaults
20 *
21 * This routine sets all of the TV encoder registers to default values for
22 * the specified format.  Currently only NTSC is supported.
23 *-----------------------------------------------------------------------------
24 */
25#if GFX_TV_DYNAMIC
26int
27geode_set_tv_defaults(int format)
28#else
29int
30gfx_set_tv_defaults(int format)
31#endif
32{
33   /* SET DEFAULTS FOR NTSC */
34
35   WRITE_VID32(SC1400_TVOUT_HORZ_TIM, 0x00790359);
36   WRITE_VID32(SC1400_TVOUT_HORZ_SYNC, 0x03580350);
37   WRITE_VID32(SC1400_TVOUT_VERT_SYNC, 0x0A002001);
38   WRITE_VID32(SC1400_TVOUT_LINE_END, 0x039C00F0);
39   WRITE_VID32(SC1400_TVOUT_VERT_DOWNSCALE, 0xFFFFFFFF);
40   WRITE_VID32(SC1400_TVOUT_HORZ_SCALING, 0x10220700);
41   WRITE_VID32(SC1400_TVOUT_EMMA_BYPASS, 0x0002D0F0);
42   WRITE_VID32(SC1400_TVENC_TIM_CTRL_1, 0xA2E03000);
43   WRITE_VID32(SC1400_TVENC_TIM_CTRL_2, 0x1FF20000);
44   WRITE_VID32(SC1400_TVENC_TIM_CTRL_3, 0x00000000);
45   WRITE_VID32(SC1400_TVENC_SUB_FREQ, 0x21F12000);
46   WRITE_VID32(SC1400_TVENC_DISP_POS, 0x00030071);
47   WRITE_VID32(SC1400_TVENC_DISP_SIZE, 0x00EF02CF);
48
49   /* ### ADD ### DEFAULTS FOR PAL */
50   return (0);
51}
52
53/*-----------------------------------------------------------------------------
54 * gfx_set_tv_enable
55 *
56 * This routine enables or disables the TV output.
57 *-----------------------------------------------------------------------------
58 */
59#if GFX_TV_DYNAMIC
60int
61geode_set_tv_enable(int enable)
62#else
63int
64gfx_set_tv_enable(int enable)
65#endif
66{
67   unsigned long value;
68
69   value = READ_VID32(SC1400_DISPLAY_CONFIG);
70   if (enable)
71      value |= SC1400_DCFG_TVOUT_EN;
72   else
73      value &= ~(SC1400_DCFG_TVOUT_EN);
74   WRITE_VID32(SC1400_DISPLAY_CONFIG, value);
75   return (0);
76}
77
78/*-----------------------------------------------------------------------------
79 * gfx_set_tv_cc_enable
80 *
81 * This routine enables or disables the use of the hardware CC registers
82 * in the TV encoder.
83 *-----------------------------------------------------------------------------
84 */
85#if GFX_TV_DYNAMIC
86int
87geode_set_tv_cc_enable(int enable)
88#else
89int
90gfx_set_tv_cc_enable(int enable)
91#endif
92{
93   unsigned long value;
94
95   value = READ_VID32(SC1400_TVENC_CC_CONTROL);
96   value &= ~(0x0005F);
97   if (enable)
98      value |= 0x51;
99   WRITE_VID32(SC1400_TVENC_CC_CONTROL, value);
100   return (0);
101}
102
103/*-----------------------------------------------------------------------------
104 * gfx_set_tv_cc_data
105 *
106 * This routine writes the two specified characters to the CC data register
107 * of the TV encoder.
108 *-----------------------------------------------------------------------------
109 */
110#if GFX_TV_DYNAMIC
111int
112geode_set_tv_cc_data(unsigned char data1, unsigned char data2)
113#else
114int
115gfx_set_tv_cc_data(unsigned char data1, unsigned char data2)
116#endif
117{
118   unsigned long value;
119
120   value = data1 | (((unsigned long)data2) << 8);
121   WRITE_VID32(SC1400_TVENC_CC_DATA, value);
122   return (0);
123}
124
125/* END OF FILE */
126