30 #ifndef LINUX_EM8300_H
31 #define LINUX_EM8300_H
81 #define MAX_UCODE_REGISTER 110
83 #define EM8300_IOCTL_INIT _IOW('C',0,em8300_microcode_t)
84 #define EM8300_IOCTL_READREG _IOWR('C',1,em8300_register_t)
85 #define EM8300_IOCTL_WRITEREG _IOW('C',2,em8300_register_t)
86 #define EM8300_IOCTL_GETSTATUS _IOR('C',3,char[1024])
87 #define EM8300_IOCTL_SETBCS _IOW('C',4,em8300_bcs_t)
88 #define EM8300_IOCTL_GETBCS _IOR('C',4,em8300_bcs_t)
89 #define EM8300_IOCTL_SET_ASPECTRATIO _IOW('C',5,int)
90 #define EM8300_IOCTL_GET_ASPECTRATIO _IOR('C',5,int)
91 #define EM8300_IOCTL_SET_VIDEOMODE _IOW('C',6,int)
92 #define EM8300_IOCTL_GET_VIDEOMODE _IOR('C',6,int)
93 #define EM8300_IOCTL_SET_PLAYMODE _IOW('C',7,int)
94 #define EM8300_IOCTL_GET_PLAYMODE _IOR('C',7,int)
95 #define EM8300_IOCTL_SET_AUDIOMODE _IOW('C',8,int)
96 #define EM8300_IOCTL_GET_AUDIOMODE _IOR('C',8,int)
97 #define EM8300_IOCTL_SET_SPUMODE _IOW('C',9,int)
98 #define EM8300_IOCTL_GET_SPUMODE _IOR('C',9,int)
99 #define EM8300_IOCTL_OVERLAY_CALIBRATE _IOWR('C',10,em8300_overlay_calibrate_t)
100 #define EM8300_IOCTL_OVERLAY_SETMODE _IOW('C',11,int)
101 #define EM8300_IOCTL_OVERLAY_SETWINDOW _IOWR('C',12,em8300_overlay_window_t)
102 #define EM8300_IOCTL_OVERLAY_SETSCREEN _IOWR('C',13,em8300_overlay_screen_t)
103 #define EM8300_IOCTL_OVERLAY_GET_ATTRIBUTE _IOR('C',14,em8300_attribute_t)
104 #define EM8300_IOCTL_OVERLAY_SET_ATTRIBUTE _IOW('C',14,em8300_attribute_t)
105 #define EM8300_IOCTL_OVERLAY_SIGNALMODE _IOW('C',15,em8300_attribute_t)
106 #define EM8300_IOCTL_SCR_GET _IOR('C',16,unsigned)
107 #define EM8300_IOCTL_SCR_SET _IOW('C',16,unsigned)
108 #define EM8300_IOCTL_SCR_GETSPEED _IOR('C',17,unsigned)
109 #define EM8300_IOCTL_SCR_SETSPEED _IOW('C',17,unsigned)
110 #define EM8300_IOCTL_FLUSH _IOW('C',18,int)
111 #define EM8300_IOCTL_VBI _IOW('C',19,struct timeval)
113 #define EM8300_OVERLAY_SIGNAL_ONLY 1
114 #define EM8300_OVERLAY_SIGNAL_WITH_VGA 2
115 #define EM8300_OVERLAY_VGA_ONLY 3
117 #define EM8300_IOCTL_VIDEO_SETPTS _IOW('C',1,int)
118 #define EM8300_IOCTL_VIDEO_GETSCR _IOR('C',2,unsigned)
119 #define EM8300_IOCTL_VIDEO_SETSCR _IOW('C',2,unsigned)
121 #define EM8300_IOCTL_SPU_SETPTS _IOW('C',1,int)
122 #define EM8300_IOCTL_SPU_SETPALETTE _IOW('C',2,unsigned[16])
123 #define EM8300_IOCTL_SPU_BUTTON _IOW('C',3,em8300_button_t)
125 #define EM8300_ASPECTRATIO_4_3 0
126 #define EM8300_ASPECTRATIO_16_9 1
127 #define EM8300_ASPECTRATIO_LAST 1
129 #define EM8300_VIDEOMODE_PAL 0
130 #define EM8300_VIDEOMODE_PAL60 1
131 #define EM8300_VIDEOMODE_NTSC 2
132 #define EM8300_VIDEOMODE_LAST 2
133 #ifndef EM8300_VIDEOMODE_DEFAULT
134 #define EM8300_VIDEOMODE_DEFAULT EM8300_VIDEOMODE_PAL
137 #define EM8300_AUDIOMODE_ANALOG 0
138 #define EM8300_AUDIOMODE_DIGITALPCM 1
139 #define EM8300_AUDIOMODE_DIGITALAC3 2
140 #ifndef EM8300_AUDIOMODE_DEFAULT
141 #define EM8300_AUDIOMODE_DEFAULT EM8300_AUDIOMODE_ANALOG
144 #define EM8300_SPUMODE_OFF 0
145 #define EM8300_SPUMODE_ON 1
147 #define EM8300_PLAYMODE_STOPPED 0
148 #define EM8300_PLAYMODE_PAUSED 1
149 #define EM8300_PLAYMODE_SLOWFORWARDS 2
150 #define EM8300_PLAYMODE_SLOWBACKWARDS 3
151 #define EM8300_PLAYMODE_SINGLESTEP 4
152 #define EM8300_PLAYMODE_PLAY 5
153 #define EM8300_PLAYMODE_REVERSEPLAY 6
154 #define EM8300_PLAYMODE_SCAN 7
155 #define EM8300_PLAYMODE_FRAMEBUF 8
157 #define EM8300_OVERLAY_MODE_OFF 0
158 #define EM8300_OVERLAY_MODE_RECTANGLE 1
159 #define EM8300_OVERLAY_MODE_OVERLAY 2
161 #define EM8300_OVERLAY_CALMODE_XOFFSET 1
162 #define EM8300_OVERLAY_CALMODE_YOFFSET 2
163 #define EM8300_OVERLAY_CALMODE_XCORRECTION 3
164 #define EM8300_OVERLAY_CALMODE_COLOR 4
166 #define EM9010_ATTRIBUTE_XCORR 1
167 #define EM9010_ATTRIBUTE_XOFFSET 2
168 #define EM9010_ATTRIBUTE_YOFFSET 3
169 #define EM9010_ATTRIBUTE_JITTER 4
170 #define EM9010_ATTRIBUTE_STABILITY 5
171 #define EM9010_ATTRIBUTE_KEYCOLOR_UPPER 6
172 #define EM9010_ATTRIBUTE_KEYCOLOR_LOWER 7
173 #define EM9010_ATTRIBUTE_MAX 7
175 #define EM8300_SUBDEVICE_CONTROL 0
176 #define EM8300_SUBDEVICE_VIDEO 1
177 #define EM8300_SUBDEVICE_AUDIO 2
178 #define EM8300_SUBDEVICE_SUBPICTURE 3
180 #ifndef PCI_VENDOR_ID_SIGMADESIGNS
181 #define PCI_VENDOR_ID_SIGMADESIGNS 0x1105
182 #define PCI_DEVICE_ID_SIGMADESIGNS_EM8300 0x8300
185 #define CLOCKGEN_SAMPFREQ_MASK 0xc0
186 #define CLOCKGEN_SAMPFREQ_66 0xc0
187 #define CLOCKGEN_SAMPFREQ_48 0x40
188 #define CLOCKGEN_SAMPFREQ_44 0x80
189 #define CLOCKGEN_SAMPFREQ_32 0x00
191 #define CLOCKGEN_OUTMASK 0x30
192 #define CLOCKGEN_DIGITALOUT 0x10
193 #define CLOCKGEN_ANALOGOUT 0x20
195 #define CLOCKGEN_MODEMASK 0x0f
196 #define CLOCKGEN_OVERLAYMODE_1 0x07
197 #define CLOCKGEN_TVMODE_1 0x0b
198 #define CLOCKGEN_OVERLAYMODE_2 0x04
199 #define CLOCKGEN_TVMODE_2 0x02
201 #define MVCOMMAND_STOP 0x0
202 #define MVCOMMAND_PAUSE 0x1
203 #define MVCOMMAND_START 0x3
204 #define MVCOMMAND_PLAYINTRA 0x4
205 #define MVCOMMAND_SYNC 0x6
206 #define MVCOMMAND_FLUSHBUF 0x10
207 #define MVCOMMAND_DISPLAYBUFINFO 0x11
209 #define MACOMMAND_STOP 0x0
210 #define MACOMMAND_PAUSE 0x1
211 #define MACOMMAND_PLAY 0x2
213 #define IRQSTATUS_VIDEO_VBL 0x10
214 #define IRQSTATUS_VIDEO_FIFO 0x2
215 #define IRQSTATUS_AUDIO_FIFO 0x8
217 #define ENCODER_UNKNOWN 0
218 #define ENCODER_ADV7175 1
219 #define ENCODER_ADV7170 2
220 #define ENCODER_BT865 3
226 #define EM8300_MAJOR 121
227 #define EM8300_LOGNAME "em8300"
230 #include <linux/version.h>
231 #include <linux/types.h>
232 #include <linux/i2c.h>
233 #include <linux/i2c-algo-bit.h>
234 #include <linux/time.h>
235 #include <linux/wait.h>
236 #include <linux/list.h>
238 #if defined(CONFIG_SND) || defined(CONFIG_SND_MODULE)
239 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
240 #define snd_card_t struct snd_card
242 #include <sound/driver.h>
243 #include <sound/core.h>
244 #include <sound/pcm.h>
262 struct displaybuffer_info_s {
275 struct em8300_audio_s {
283 struct em8300_model_config_s {
288 int bt865_ucode_timeout;
289 int activate_loopback;
292 struct adv717x_model_config_s {
294 int pixelport_other_pal;
295 int pixeldata_adjust_ntsc;
296 int pixeldata_adjust_pal;
299 struct bt865_model_config_s {
302 struct em8300_config_s {
303 struct em8300_model_config_s model;
304 struct adv717x_model_config_s adv717x_model;
305 struct bt865_model_config_s bt865_model;
321 volatile unsigned *mem;
326 #if defined(CONFIG_SND) || defined(CONFIG_SND_MODULE)
327 snd_card_t *alsa_card;
331 struct fifo_s *mvfifo;
332 struct fifo_s *mafifo;
333 struct fifo_s *spfifo;
337 int dicom_vertoffset;
338 int dicom_horizoffset;
339 int dicom_brightness;
341 int dicom_saturation;
343 struct displaybuffer_info_s dbuf_info;
353 struct i2c_algo_bit_data i2c_data_1;
354 struct i2c_adapter i2c_ops_1;
357 struct i2c_algo_bit_data i2c_data_2;
358 struct i2c_adapter i2c_ops_2;
362 struct i2c_client *encoder;
363 struct i2c_client *eeprom;
376 int clockgen_overlaymode;
380 struct timeval tv, last_status_time;
387 struct em8300_audio_s audio;
392 unsigned int channel_status_pos;
393 unsigned char channel_status[24];
394 enum { NONE, OSS, ALSA } audio_driver_style;
395 struct semaphore audio_driver_style_lock;
403 uint32_t video_lastpts;
404 int video_ptsvalid,video_offset,video_count;
405 int video_ptsfifo_ptr;
406 #if LINUX_VERSION_CODE < 0x020314
407 struct wait_queue *video_ptsfifo_wait;
408 struct wait_queue *vbi_wait;
410 wait_queue_head_t video_ptsfifo_wait;
411 wait_queue_head_t vbi_wait;
413 int video_ptsfifo_waiting;
418 int sp_pts, sp_ptsvalid, sp_count;
420 #if LINUX_VERSION_CODE < 0x020314
421 struct wait_queue *sp_ptsfifo_wait;
423 wait_queue_head_t sp_ptsfifo_wait;
425 int sp_ptsfifo_waiting;
433 int overlay_gamma_enable;
436 int overlay_frame_xpos;
437 int overlay_frame_ypos;
438 int overlay_frame_width;
439 int overlay_frame_height;
441 int overlay_double_y;
442 int overlay_xcorr_default;
444 int overlay_dword_24bb8;
446 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,0)
448 struct list_head memory;
456 struct em8300_config_s config;
459 unsigned int card_nr;
462 #if defined(CONFIG_SND) || defined(CONFIG_SND_MODULE)
463 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
468 #define TIMEDIFF(a,b) a.tv_usec - b.tv_usec + \
469 1000000 * (a.tv_sec - b.tv_sec)
477 int em8300_i2c_init1(
struct em8300_s *em);
478 int em8300_i2c_init2(
struct em8300_s *em);
479 void em8300_i2c_exit(
struct em8300_s *em);
480 void em8300_clockgen_write(
struct em8300_s *em,
int abyte);
482 void em9010_write(
struct em8300_s *em,
int reg,
int data);
483 int em9010_read(
struct em8300_s *em,
int reg);
484 int em9010_read16(
struct em8300_s *em,
int reg);
485 void em9010_write16(
struct em8300_s *em,
int reg,
int value);
488 int em8300_audio_ioctl(
struct em8300_s *em,
unsigned int cmd,
unsigned long arg);
489 int em8300_audio_flush(
struct em8300_s *em);
490 int em8300_audio_open(
struct em8300_s *em);
491 int em8300_audio_release(
struct em8300_s *em);
492 int em8300_audio_setup(
struct em8300_s *em);
493 ssize_t em8300_audio_write(
struct em8300_s *em,
const char * buf,
494 size_t count, loff_t *ppos);
495 int mpegaudio_command(
struct em8300_s *em,
int cmd);
498 void em8300_ucode_upload(
struct em8300_s *em,
void *ucode,
int ucode_size);
499 void em8300_require_ucode(
struct em8300_s *em);
502 int em8300_setregblock(
struct em8300_s *em,
int offset,
int val,
int len);
503 int em8300_writeregblock(
struct em8300_s *em,
int offset,
unsigned *buf,
int len);
504 int em8300_waitfor(
struct em8300_s *em,
int reg,
int val,
int mask);
505 int em8300_waitfor_not(
struct em8300_s *em,
int reg,
int val,
int mask);
508 void em8300_dicom_setBCS(
struct em8300_s *em,
int brightness,
int contrast,
int saturation);
509 void em8300_dicom_enable(
struct em8300_s *em);
510 void em8300_dicom_disable(
struct em8300_s *em);
511 int em8300_dicom_update(
struct em8300_s *em);
512 void em8300_dicom_init(
struct em8300_s *em);
513 int em8300_dicom_get_dbufinfo(
struct em8300_s *em);
514 void em8300_dicom_fill_dispbuffers(
struct em8300_s *em,
int xpos,
int ypos,
int xsize,
515 int ysize,
unsigned int pat1,
unsigned int pat2);
518 void em8300_video_open(
struct em8300_s *em);
519 int em8300_video_setplaymode(
struct em8300_s *em,
int mode);
520 int em8300_video_sync(
struct em8300_s *em);
521 int em8300_video_flush(
struct em8300_s *em);
522 int em8300_video_setup(
struct em8300_s *em);
523 int em8300_video_release(
struct em8300_s *em);
524 void em8300_video_setspeed(
struct em8300_s *em,
int speed);
525 ssize_t em8300_video_write(
struct em8300_s *em,
const char * buf,
526 size_t count, loff_t *ppos);
527 int em8300_video_ioctl(
struct em8300_s *em,
unsigned int cmd,
unsigned long arg);
528 void em8300_video_check_ptsfifo(
struct em8300_s *em);
531 ssize_t em8300_spu_write(
struct em8300_s *em,
const char * buf,
532 size_t count, loff_t *ppos);
533 int em8300_spu_open(
struct em8300_s *em);
534 int em8300_spu_ioctl(
struct em8300_s *em,
unsigned int cmd,
unsigned long arg);
535 int em8300_spu_init(
struct em8300_s *em);
536 void em8300_spu_check_ptsfifo(
struct em8300_s *em);
537 int em8300_ioctl_setspumode(
struct em8300_s *em,
int mode);
538 void em8300_spu_release(
struct em8300_s *em);
541 int em8300_control_ioctl(
struct em8300_s *em,
int cmd,
unsigned long arg);
542 int em8300_ioctl_setvideomode(
struct em8300_s *em,
int mode);
543 int em8300_ioctl_setaspectratio(
struct em8300_s *em,
int ratio);
544 int em8300_ioctl_getstatus(
struct em8300_s *em,
char *usermsg);
546 void em8300_ioctl_enable_videoout(
struct em8300_s *em,
int mode);
547 int em8300_ioctl_setplaymode(
struct em8300_s *em,
int mode);
548 int em8300_ioctl_setaudiomode(
struct em8300_s *em,
int mode);
549 int em8300_ioctl_getaudiomode(
struct em8300_s *em,
long int mode);
553 int em8300_ioctl_overlay_setmode(
struct em8300_s *em,
int val);
556 int em9010_cabledetect(
struct em8300_s *em);
557 int em9010_calibrate_xoffset(
struct em8300_s *em);
558 int em9010_calibrate_yoffset(
struct em8300_s *em);
559 int em9010_init(
struct em8300_s *em);
560 int em9010_overlay_set_signalmode(
struct em8300_s *em,
int val);
561 int em9010_overlay_update(
struct em8300_s *em);
562 int em9010_overlay_set_res(
struct em8300_s *em,
int xres,
int yres);
563 void sub_4288c(
struct em8300_s *em,
int pa,
int pb,
int pc,
int pd,
int pe,
int pf,
565 int em9010_get_attribute(
struct em8300_s *em,
int attribute);
566 int em9010_set_attribute(
struct em8300_s *em,
int attribute,
int value);