2 * Frame buffer driver for ADV7393/2 video encoder
4 * Copyright 2006-2009 Analog Devices Inc.
5 * Licensed under the GPL-2 or late.
8 #ifndef __BFIN_ADV7393FB_H__
9 #define __BFIN_ADV7393FB_H__
11 #define BFIN_LCD_NBR_PALETTE_ENTRIES 256
19 #ifdef CONFIG_NTSC_640x480
22 #ifdef CONFIG_PAL_640x480
25 #ifdef CONFIG_NTSC_YCBCR
28 #ifdef CONFIG_PAL_YCBCR
36 #ifdef CONFIG_ADV7393_2XMEM
42 #if defined(CONFIG_BF537) || defined(CONFIG_BF536) || defined(CONFIG_BF534)
43 # define DMA_CFG_VAL 0x7935 /* Set Sync Bit */
44 # define VB_DUMMY_MEMORY_SOURCE L1_DATA_B_START
46 # define DMA_CFG_VAL 0x7915
47 # define VB_DUMMY_MEMORY_SOURCE BOOT_ROM_START
62 struct adv7393fb_modes
{
63 const s8 name
[25]; /* Full name */
64 u16 xres
; /* Active Horizonzal Pixels */
65 u16 yres
; /* Active Vertical Pixels */
68 u16 a_lines
; /* Active Lines per Field */
69 u16 vb1_lines
; /* Vertical Blanking Field 1 Lines */
70 u16 vb2_lines
; /* Vertical Blanking Field 2 Lines */
71 u16 tot_lines
; /* Total Lines per Frame */
72 u16 boeft_blank
; /* Before Odd/Even Field Transition No. of Blank Pixels */
73 u16 aoeft_blank
; /* After Odd/Even Field Transition No. of Blank Pixels */
74 const s8
*adv7393_i2c_initd
;
75 u16 adv7393_i2c_initd_len
;
78 static const u8 init_NTSC_TESTPATTERN
[] = {
79 0x00, 0x1E, /* Power up all DACs and PLL */
80 0x01, 0x00, /* SD-Only Mode */
81 0x80, 0x10, /* SSAF Luma Filter Enabled, NTSC Mode */
82 0x82, 0xCB, /* Step control on, pixel data valid, pedestal on, PrPb SSAF on, CVBS/YC output */
83 0x84, 0x40, /* SD Color Bar Test Pattern Enabled, DAC 2 = Luma, DAC 3 = Chroma */
86 static const u8 init_NTSC
[] = {
87 0x00, 0x1E, /* Power up all DACs and PLL */
88 0xC3, 0x26, /* Program RGB->YCrCb Color Space conversion matrix */
89 0xC5, 0x12, /* Program RGB->YCrCb Color Space conversion matrix */
90 0xC2, 0x4A, /* Program RGB->YCrCb Color Space conversion matrix */
91 0xC6, 0x5E, /* Program RGB->YCrCb Color Space conversion matrix */
92 0xBD, 0x19, /* Program RGB->YCrCb Color Space conversion matrix */
93 0xBF, 0x42, /* Program RGB->YCrCb Color Space conversion matrix */
94 0x8C, 0x1F, /* NTSC Subcarrier Frequency */
95 0x8D, 0x7C, /* NTSC Subcarrier Frequency */
96 0x8E, 0xF0, /* NTSC Subcarrier Frequency */
97 0x8F, 0x21, /* NTSC Subcarrier Frequency */
98 0x01, 0x00, /* SD-Only Mode */
99 0x80, 0x30, /* SSAF Luma Filter Enabled, NTSC Mode */
100 0x82, 0x8B, /* Step control on, pixel data invalid, pedestal on, PrPb SSAF on, CVBS/YC output */
101 0x87, 0x80, /* SD Color Bar Test Pattern Enabled, DAC 2 = Luma, DAC 3 = Chroma */
108 static const u8 init_PAL
[] = {
109 0x00, 0x1E, /* Power up all DACs and PLL */
110 0xC3, 0x26, /* Program RGB->YCrCb Color Space conversion matrix */
111 0xC5, 0x12, /* Program RGB->YCrCb Color Space conversion matrix */
112 0xC2, 0x4A, /* Program RGB->YCrCb Color Space conversion matrix */
113 0xC6, 0x5E, /* Program RGB->YCrCb Color Space conversion matrix */
114 0xBD, 0x19, /* Program RGB->YCrCb Color Space conversion matrix */
115 0xBF, 0x42, /* Program RGB->YCrCb Color Space conversion matrix */
116 0x8C, 0xCB, /* PAL Subcarrier Frequency */
117 0x8D, 0x8A, /* PAL Subcarrier Frequency */
118 0x8E, 0x09, /* PAL Subcarrier Frequency */
119 0x8F, 0x2A, /* PAL Subcarrier Frequency */
120 0x01, 0x00, /* SD-Only Mode */
121 0x80, 0x11, /* SSAF Luma Filter Enabled, PAL Mode */
122 0x82, 0x8B, /* Step control on, pixel data invalid, pedestal on, PrPb SSAF on, CVBS/YC output */
123 0x87, 0x80, /* SD Color Bar Test Pattern Enabled, DAC 2 = Luma, DAC 3 = Chroma */
130 static const u8 init_NTSC_YCbCr
[] = {
131 0x00, 0x1E, /* Power up all DACs and PLL */
132 0x8C, 0x1F, /* NTSC Subcarrier Frequency */
133 0x8D, 0x7C, /* NTSC Subcarrier Frequency */
134 0x8E, 0xF0, /* NTSC Subcarrier Frequency */
135 0x8F, 0x21, /* NTSC Subcarrier Frequency */
136 0x01, 0x00, /* SD-Only Mode */
137 0x80, 0x30, /* SSAF Luma Filter Enabled, NTSC Mode */
138 0x82, 0x8B, /* Step control on, pixel data invalid, pedestal on, PrPb SSAF on, CVBS/YC output */
139 0x87, 0x00, /* DAC 2 = Luma, DAC 3 = Chroma */
146 static const u8 init_PAL_YCbCr
[] = {
147 0x00, 0x1E, /* Power up all DACs and PLL */
148 0x8C, 0xCB, /* PAL Subcarrier Frequency */
149 0x8D, 0x8A, /* PAL Subcarrier Frequency */
150 0x8E, 0x09, /* PAL Subcarrier Frequency */
151 0x8F, 0x2A, /* PAL Subcarrier Frequency */
152 0x01, 0x00, /* SD-Only Mode */
153 0x80, 0x11, /* SSAF Luma Filter Enabled, PAL Mode */
154 0x82, 0x8B, /* Step control on, pixel data invalid, pedestal on, PrPb SSAF on, CVBS/YC output */
155 0x87, 0x00, /* DAC 2 = Luma, DAC 3 = Chroma */
162 static struct adv7393fb_modes known_modes
[] = {
163 /* NTSC 720x480 CRT */
165 .name
= "NTSC 720x480",
169 .vmode
= FB_VMODE_INTERLACED
,
176 .adv7393_i2c_initd
= init_NTSC
,
177 .adv7393_i2c_initd_len
= sizeof(init_NTSC
)
179 /* PAL 720x480 CRT */
181 .name
= "PAL 720x576",
185 .vmode
= FB_VMODE_INTERLACED
,
192 .adv7393_i2c_initd
= init_PAL
,
193 .adv7393_i2c_initd_len
= sizeof(init_PAL
)
195 /* NTSC 640x480 CRT Experimental */
197 .name
= "NTSC 640x480",
201 .vmode
= FB_VMODE_INTERLACED
,
206 .boeft_blank
= 16 + 40,
207 .aoeft_blank
= 122 + 40,
208 .adv7393_i2c_initd
= init_NTSC
,
209 .adv7393_i2c_initd_len
= sizeof(init_NTSC
)
211 /* PAL 640x480 CRT Experimental */
213 .name
= "PAL 640x480",
217 .vmode
= FB_VMODE_INTERLACED
,
219 .vb1_lines
= 24 + 20,
220 .vb2_lines
= 25 + 20,
222 .boeft_blank
= 12 + 40,
223 .aoeft_blank
= 132 + 40,
224 .adv7393_i2c_initd
= init_PAL
,
225 .adv7393_i2c_initd_len
= sizeof(init_PAL
)
227 /* NTSC 720x480 YCbCR */
229 .name
= "NTSC 720x480 YCbCR",
233 .vmode
= FB_VMODE_INTERLACED
,
240 .adv7393_i2c_initd
= init_NTSC_YCbCr
,
241 .adv7393_i2c_initd_len
= sizeof(init_NTSC_YCbCr
)
243 /* PAL 720x480 CRT */
245 .name
= "PAL 720x576 YCbCR",
249 .vmode
= FB_VMODE_INTERLACED
,
256 .adv7393_i2c_initd
= init_PAL_YCbCr
,
257 .adv7393_i2c_initd_len
= sizeof(init_PAL_YCbCr
)
261 struct adv7393fb_regs
{
265 struct adv7393fb_device
{
266 struct fb_info info
; /* FB driver info record */
268 struct i2c_client
*client
;
270 struct dmasg
*descriptor_list_head
;
276 dma_addr_t dma_handle
;
278 struct fb_info bfin_adv7393_fb
;
280 struct adv7393fb_modes
*modes
;
282 struct adv7393fb_regs
*regs
; /* Registers memory map */
287 u16
*fb_mem
; /* RGB Buffer */
291 #define to_adv7393fb_device(_info) \
292 (_info ? container_of(_info, struct adv7393fb_device, info) : NULL);
294 static int bfin_adv7393_fb_open(struct fb_info
*info
, int user
);
295 static int bfin_adv7393_fb_release(struct fb_info
*info
, int user
);
296 static int bfin_adv7393_fb_check_var(struct fb_var_screeninfo
*var
,
297 struct fb_info
*info
);
299 static int bfin_adv7393_fb_pan_display(struct fb_var_screeninfo
*var
,
300 struct fb_info
*info
);
302 static int bfin_adv7393_fb_blank(int blank
, struct fb_info
*info
);
304 static void bfin_config_ppi(struct adv7393fb_device
*fbdev
);
305 static int bfin_config_dma(struct adv7393fb_device
*fbdev
);
306 static void bfin_disable_dma(void);
307 static void bfin_enable_ppi(void);
308 static void bfin_disable_ppi(void);
310 static inline int adv7393_write(struct i2c_client
*client
, u8 reg
, u8 value
);
311 static inline int adv7393_read(struct i2c_client
*client
, u8 reg
);
312 static int adv7393_write_block(struct i2c_client
*client
, const u8
*data
,
315 int bfin_adv7393_fb_cursor(struct fb_info
*info
, struct fb_cursor
*cursor
);
316 static int bfin_adv7393_fb_setcolreg(u_int
, u_int
, u_int
, u_int
,
317 u_int
, struct fb_info
*info
);