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
#define DRIVER_NAME "bfin-adv7393"
64
struct adv7393fb_modes {
65
const s8 name[25]; /* Full name */
66
u16 xres; /* Active Horizonzal Pixels */
67
u16 yres; /* Active Vertical Pixels */
70
u16 a_lines; /* Active Lines per Field */
71
u16 vb1_lines; /* Vertical Blanking Field 1 Lines */
72
u16 vb2_lines; /* Vertical Blanking Field 2 Lines */
73
u16 tot_lines; /* Total Lines per Frame */
74
u16 boeft_blank; /* Before Odd/Even Field Transition No. of Blank Pixels */
75
u16 aoeft_blank; /* After Odd/Even Field Transition No. of Blank Pixels */
76
const s8 *adv7393_i2c_initd;
77
u16 adv7393_i2c_initd_len;
80
static const u8 init_NTSC_TESTPATTERN[] = {
81
0x00, 0x1E, /* Power up all DACs and PLL */
82
0x01, 0x00, /* SD-Only Mode */
83
0x80, 0x10, /* SSAF Luma Filter Enabled, NTSC Mode */
84
0x82, 0xCB, /* Step control on, pixel data valid, pedestal on, PrPb SSAF on, CVBS/YC output */
85
0x84, 0x40, /* SD Color Bar Test Pattern Enabled, DAC 2 = Luma, DAC 3 = Chroma */
88
static const u8 init_NTSC[] = {
89
0x00, 0x1E, /* Power up all DACs and PLL */
90
0xC3, 0x26, /* Program RGB->YCrCb Color Space conversion matrix */
91
0xC5, 0x12, /* Program RGB->YCrCb Color Space conversion matrix */
92
0xC2, 0x4A, /* Program RGB->YCrCb Color Space conversion matrix */
93
0xC6, 0x5E, /* Program RGB->YCrCb Color Space conversion matrix */
94
0xBD, 0x19, /* Program RGB->YCrCb Color Space conversion matrix */
95
0xBF, 0x42, /* Program RGB->YCrCb Color Space conversion matrix */
96
0x8C, 0x1F, /* NTSC Subcarrier Frequency */
97
0x8D, 0x7C, /* NTSC Subcarrier Frequency */
98
0x8E, 0xF0, /* NTSC Subcarrier Frequency */
99
0x8F, 0x21, /* NTSC Subcarrier Frequency */
100
0x01, 0x00, /* SD-Only Mode */
101
0x80, 0x30, /* SSAF Luma Filter Enabled, NTSC Mode */
102
0x82, 0x8B, /* Step control on, pixel data invalid, pedestal on, PrPb SSAF on, CVBS/YC output */
103
0x87, 0x80, /* SD Color Bar Test Pattern Enabled, DAC 2 = Luma, DAC 3 = Chroma */
110
static const u8 init_PAL[] = {
111
0x00, 0x1E, /* Power up all DACs and PLL */
112
0xC3, 0x26, /* Program RGB->YCrCb Color Space conversion matrix */
113
0xC5, 0x12, /* Program RGB->YCrCb Color Space conversion matrix */
114
0xC2, 0x4A, /* Program RGB->YCrCb Color Space conversion matrix */
115
0xC6, 0x5E, /* Program RGB->YCrCb Color Space conversion matrix */
116
0xBD, 0x19, /* Program RGB->YCrCb Color Space conversion matrix */
117
0xBF, 0x42, /* Program RGB->YCrCb Color Space conversion matrix */
118
0x8C, 0xCB, /* PAL Subcarrier Frequency */
119
0x8D, 0x8A, /* PAL Subcarrier Frequency */
120
0x8E, 0x09, /* PAL Subcarrier Frequency */
121
0x8F, 0x2A, /* PAL Subcarrier Frequency */
122
0x01, 0x00, /* SD-Only Mode */
123
0x80, 0x11, /* SSAF Luma Filter Enabled, PAL Mode */
124
0x82, 0x8B, /* Step control on, pixel data invalid, pedestal on, PrPb SSAF on, CVBS/YC output */
125
0x87, 0x80, /* SD Color Bar Test Pattern Enabled, DAC 2 = Luma, DAC 3 = Chroma */
132
static const u8 init_NTSC_YCbCr[] = {
133
0x00, 0x1E, /* Power up all DACs and PLL */
134
0x8C, 0x1F, /* NTSC Subcarrier Frequency */
135
0x8D, 0x7C, /* NTSC Subcarrier Frequency */
136
0x8E, 0xF0, /* NTSC Subcarrier Frequency */
137
0x8F, 0x21, /* NTSC Subcarrier Frequency */
138
0x01, 0x00, /* SD-Only Mode */
139
0x80, 0x30, /* SSAF Luma Filter Enabled, NTSC Mode */
140
0x82, 0x8B, /* Step control on, pixel data invalid, pedestal on, PrPb SSAF on, CVBS/YC output */
141
0x87, 0x00, /* DAC 2 = Luma, DAC 3 = Chroma */
148
static const u8 init_PAL_YCbCr[] = {
149
0x00, 0x1E, /* Power up all DACs and PLL */
150
0x8C, 0xCB, /* PAL Subcarrier Frequency */
151
0x8D, 0x8A, /* PAL Subcarrier Frequency */
152
0x8E, 0x09, /* PAL Subcarrier Frequency */
153
0x8F, 0x2A, /* PAL Subcarrier Frequency */
154
0x01, 0x00, /* SD-Only Mode */
155
0x80, 0x11, /* SSAF Luma Filter Enabled, PAL Mode */
156
0x82, 0x8B, /* Step control on, pixel data invalid, pedestal on, PrPb SSAF on, CVBS/YC output */
157
0x87, 0x00, /* DAC 2 = Luma, DAC 3 = Chroma */
164
static struct adv7393fb_modes known_modes[] = {
165
/* NTSC 720x480 CRT */
167
.name = "NTSC 720x480",
171
.vmode = FB_VMODE_INTERLACED,
178
.adv7393_i2c_initd = init_NTSC,
179
.adv7393_i2c_initd_len = sizeof(init_NTSC)
181
/* PAL 720x480 CRT */
183
.name = "PAL 720x576",
187
.vmode = FB_VMODE_INTERLACED,
194
.adv7393_i2c_initd = init_PAL,
195
.adv7393_i2c_initd_len = sizeof(init_PAL)
197
/* NTSC 640x480 CRT Experimental */
199
.name = "NTSC 640x480",
203
.vmode = FB_VMODE_INTERLACED,
208
.boeft_blank = 16 + 40,
209
.aoeft_blank = 122 + 40,
210
.adv7393_i2c_initd = init_NTSC,
211
.adv7393_i2c_initd_len = sizeof(init_NTSC)
213
/* PAL 640x480 CRT Experimental */
215
.name = "PAL 640x480",
219
.vmode = FB_VMODE_INTERLACED,
221
.vb1_lines = 24 + 20,
222
.vb2_lines = 25 + 20,
224
.boeft_blank = 12 + 40,
225
.aoeft_blank = 132 + 40,
226
.adv7393_i2c_initd = init_PAL,
227
.adv7393_i2c_initd_len = sizeof(init_PAL)
229
/* NTSC 720x480 YCbCR */
231
.name = "NTSC 720x480 YCbCR",
235
.vmode = FB_VMODE_INTERLACED,
242
.adv7393_i2c_initd = init_NTSC_YCbCr,
243
.adv7393_i2c_initd_len = sizeof(init_NTSC_YCbCr)
245
/* PAL 720x480 CRT */
247
.name = "PAL 720x576 YCbCR",
251
.vmode = FB_VMODE_INTERLACED,
258
.adv7393_i2c_initd = init_PAL_YCbCr,
259
.adv7393_i2c_initd_len = sizeof(init_PAL_YCbCr)
263
struct adv7393fb_regs {
267
struct adv7393fb_device {
268
struct fb_info info; /* FB driver info record */
270
struct i2c_client *client;
272
struct dmasg *descriptor_list_head;
278
dma_addr_t dma_handle;
280
struct fb_info bfin_adv7393_fb;
282
struct adv7393fb_modes *modes;
284
struct adv7393fb_regs *regs; /* Registers memory map */
289
u16 *fb_mem; /* RGB Buffer */
293
#define to_adv7393fb_device(_info) \
294
(_info ? container_of(_info, struct adv7393fb_device, info) : NULL);
296
static int bfin_adv7393_fb_open(struct fb_info *info, int user);
297
static int bfin_adv7393_fb_release(struct fb_info *info, int user);
298
static int bfin_adv7393_fb_check_var(struct fb_var_screeninfo *var,
299
struct fb_info *info);
301
static int bfin_adv7393_fb_pan_display(struct fb_var_screeninfo *var,
302
struct fb_info *info);
304
static int bfin_adv7393_fb_blank(int blank, struct fb_info *info);
306
static void bfin_config_ppi(struct adv7393fb_device *fbdev);
307
static int bfin_config_dma(struct adv7393fb_device *fbdev);
308
static void bfin_disable_dma(void);
309
static void bfin_enable_ppi(void);
310
static void bfin_disable_ppi(void);
312
static inline int adv7393_write(struct i2c_client *client, u8 reg, u8 value);
313
static inline int adv7393_read(struct i2c_client *client, u8 reg);
314
static int adv7393_write_block(struct i2c_client *client, const u8 *data,
317
int bfin_adv7393_fb_cursor(struct fb_info *info, struct fb_cursor *cursor);
318
static int bfin_adv7393_fb_setcolreg(u_int, u_int, u_int, u_int,
319
u_int, struct fb_info *info);