aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/em28xx/em28xx.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/em28xx/em28xx.h')
-rw-r--r--drivers/media/video/em28xx/em28xx.h166
1 files changed, 101 insertions, 65 deletions
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h
index d8fcc9e17ac0..f3bad0c1c517 100644
--- a/drivers/media/video/em28xx/em28xx.h
+++ b/drivers/media/video/em28xx/em28xx.h
@@ -25,28 +25,11 @@
25#ifndef _EM28XX_H 25#ifndef _EM28XX_H
26#define _EM28XX_H 26#define _EM28XX_H
27 27
28#include <linux/videodev.h> 28#include <linux/videodev2.h>
29#include <linux/i2c.h> 29#include <linux/i2c.h>
30#include <linux/mutex.h> 30#include <linux/mutex.h>
31#include <media/ir-kbd-i2c.h> 31#include <media/ir-kbd-i2c.h>
32 32
33/* Boards supported by driver */
34
35#define EM2800_BOARD_UNKNOWN 0
36#define EM2820_BOARD_UNKNOWN 1
37#define EM2820_BOARD_TERRATEC_CINERGY_250 2
38#define EM2820_BOARD_PINNACLE_USB_2 3
39#define EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 4
40#define EM2820_BOARD_MSI_VOX_USB_2 5
41#define EM2800_BOARD_TERRATEC_CINERGY_200 6
42#define EM2800_BOARD_LEADTEK_WINFAST_USBII 7
43#define EM2800_BOARD_KWORLD_USB2800 8
44#define EM2820_BOARD_PINNACLE_DVC_90 9
45#define EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 10
46#define EM2880_BOARD_TERRATEC_HYBRID_XS 11
47#define EM2820_BOARD_KWORLD_PVRTV2800RF 12
48#define EM2880_BOARD_TERRATEC_PRODIGY_XS 13
49
50#define UNSET -1 33#define UNSET -1
51 34
52/* maximum number of em28xx boards */ 35/* maximum number of em28xx boards */
@@ -148,10 +131,17 @@ enum enum28xx_itype {
148 EM28XX_RADIO, 131 EM28XX_RADIO,
149}; 132};
150 133
134enum em28xx_amux {
135 EM28XX_AMUX_VIDEO,
136 EM28XX_AMUX_LINE_IN,
137 EM28XX_AMUX_AC97_VIDEO,
138 EM28XX_AMUX_AC97_LINE_IN,
139};
140
151struct em28xx_input { 141struct em28xx_input {
152 enum enum28xx_itype type; 142 enum enum28xx_itype type;
153 unsigned int vmux; 143 unsigned int vmux;
154 unsigned int amux; 144 enum em28xx_amux amux;
155}; 145};
156 146
157#define INPUT(nr) (&em28xx_boards[dev->model].input[nr]) 147#define INPUT(nr) (&em28xx_boards[dev->model].input[nr])
@@ -165,19 +155,23 @@ enum em28xx_decoder {
165struct em28xx_board { 155struct em28xx_board {
166 char *name; 156 char *name;
167 int vchannels; 157 int vchannels;
168 int norm;
169 int tuner_type; 158 int tuner_type;
170 159
171 /* i2c flags */ 160 /* i2c flags */
172 unsigned int is_em2800;
173 unsigned int tda9887_conf; 161 unsigned int tda9887_conf;
174 162
175 unsigned int has_tuner:1; 163 unsigned int is_em2800:1;
176 unsigned int has_msp34xx:1; 164 unsigned int has_msp34xx:1;
165 unsigned int mts_firmware:1;
166 unsigned int has_12mhz_i2s:1;
167 unsigned int max_range_640_480:1;
168
169 unsigned int analog_gpio;
177 170
178 enum em28xx_decoder decoder; 171 enum em28xx_decoder decoder;
179 172
180 struct em28xx_input input[MAX_EM28XX_INPUT]; 173 struct em28xx_input input[MAX_EM28XX_INPUT];
174 struct em28xx_input radio;
181}; 175};
182 176
183struct em28xx_eeprom { 177struct em28xx_eeprom {
@@ -201,12 +195,26 @@ enum em28xx_dev_state {
201 DEV_MISCONFIGURED = 0x04, 195 DEV_MISCONFIGURED = 0x04,
202}; 196};
203 197
204/* tvnorms */ 198#define EM28XX_AUDIO_BUFS 5
205struct em28xx_tvnorm { 199#define EM28XX_NUM_AUDIO_PACKETS 64
206 char *name; 200#define EM28XX_AUDIO_MAX_PACKET_SIZE 196 /* static value */
207 v4l2_std_id id; 201#define EM28XX_CAPTURE_STREAM_EN 1
208 /* mode for saa7113h */ 202#define EM28XX_AUDIO 0x10
209 int mode; 203
204struct em28xx_audio {
205 char name[50];
206 char *transfer_buffer[EM28XX_AUDIO_BUFS];
207 struct urb *urb[EM28XX_AUDIO_BUFS];
208 struct usb_device *udev;
209 unsigned int capture_transfer_done;
210 struct snd_pcm_substream *capture_pcm_substream;
211
212 unsigned int hwptr_done_capture;
213 struct snd_card *sndcard;
214
215 int users, shutdown;
216 enum em28xx_stream_state capture_stream;
217 spinlock_t slock;
210}; 218};
211 219
212/* main device struct */ 220/* main device struct */
@@ -215,12 +223,17 @@ struct em28xx {
215 char name[30]; /* name (including minor) of the device */ 223 char name[30]; /* name (including minor) of the device */
216 int model; /* index in the device_data struct */ 224 int model; /* index in the device_data struct */
217 int devno; /* marks the number of this device */ 225 int devno; /* marks the number of this device */
218 unsigned int is_em2800; 226 unsigned int analog_gpio;
219 int video_inputs; /* number of video inputs */ 227 unsigned int is_em2800:1;
220 struct list_head devlist;
221 unsigned int has_tuner:1;
222 unsigned int has_msp34xx:1; 228 unsigned int has_msp34xx:1;
223 unsigned int has_tda9887:1; 229 unsigned int has_tda9887:1;
230 unsigned int stream_on:1; /* Locks streams */
231 unsigned int has_audio_class:1;
232 unsigned int has_12mhz_i2s:1;
233 unsigned int max_range_640_480:1;
234
235 int video_inputs; /* number of video inputs */
236 struct list_head devlist;
224 237
225 u32 i2s_speed; /* I2S speed for audio digital stream */ 238 u32 i2s_speed; /* I2S speed for audio digital stream */
226 239
@@ -235,8 +248,7 @@ struct em28xx {
235 /* video for linux */ 248 /* video for linux */
236 int users; /* user count for exclusive use */ 249 int users; /* user count for exclusive use */
237 struct video_device *vdev; /* video for linux device struct */ 250 struct video_device *vdev; /* video for linux device struct */
238 struct video_picture vpic; /* picture settings only used to init saa7113h */ 251 v4l2_std_id norm; /* selected tv norm */
239 struct em28xx_tvnorm *tvnorm; /* selected tv norm */
240 int ctl_freq; /* selected frequency */ 252 int ctl_freq; /* selected frequency */
241 unsigned int ctl_input; /* selected input */ 253 unsigned int ctl_input; /* selected input */
242 unsigned int ctl_ainput; /* slected audio input */ 254 unsigned int ctl_ainput; /* slected audio input */
@@ -256,17 +268,27 @@ struct em28xx {
256 int vscale; /* vertical scale factor (see datasheet) */ 268 int vscale; /* vertical scale factor (see datasheet) */
257 int interlaced; /* 1=interlace fileds, 0=just top fileds */ 269 int interlaced; /* 1=interlace fileds, 0=just top fileds */
258 int type; 270 int type;
271 unsigned int video_bytesread; /* Number of bytes read */
272
273 unsigned long hash; /* eeprom hash - for boards with generic ID */
274 unsigned long i2c_hash; /* i2c devicelist hash - for boards with generic ID */
275
276 struct em28xx_audio *adev;
259 277
260 /* states */ 278 /* states */
261 enum em28xx_dev_state state; 279 enum em28xx_dev_state state;
262 enum em28xx_stream_state stream; 280 enum em28xx_stream_state stream;
263 enum em28xx_io_method io; 281 enum em28xx_io_method io;
282
283 struct work_struct request_module_wk;
284
264 /* locks */ 285 /* locks */
265 struct mutex lock, fileop_lock; 286 struct mutex lock;
266 spinlock_t queue_lock; 287 spinlock_t queue_lock;
267 struct list_head inqueue, outqueue; 288 struct list_head inqueue, outqueue;
268 wait_queue_head_t open, wait_frame, wait_stream; 289 wait_queue_head_t open, wait_frame, wait_stream;
269 struct video_device *vbi_dev; 290 struct video_device *vbi_dev;
291 struct video_device *radio_dev;
270 292
271 unsigned char eedata[256]; 293 unsigned char eedata[256];
272 294
@@ -289,16 +311,27 @@ struct em28xx {
289 int (*em28xx_read_reg_req) (struct em28xx * dev, u8 req, u16 reg); 311 int (*em28xx_read_reg_req) (struct em28xx * dev, u8 req, u16 reg);
290}; 312};
291 313
314struct em28xx_fh {
315 struct em28xx *dev;
316 unsigned int stream_on:1; /* Locks streams */
317 int radio;
318};
319
320struct em28xx_ops {
321 struct list_head next;
322 char *name;
323 int id;
324 int (*init)(struct em28xx *);
325 int (*fini)(struct em28xx *);
326};
327
292/* Provided by em28xx-i2c.c */ 328/* Provided by em28xx-i2c.c */
293 329
294void em28xx_i2c_call_clients(struct em28xx *dev, unsigned int cmd, void *arg); 330void em28xx_i2c_call_clients(struct em28xx *dev, unsigned int cmd, void *arg);
331void em28xx_do_i2c_scan(struct em28xx *dev);
295int em28xx_i2c_register(struct em28xx *dev); 332int em28xx_i2c_register(struct em28xx *dev);
296int em28xx_i2c_unregister(struct em28xx *dev); 333int em28xx_i2c_unregister(struct em28xx *dev);
297 334
298/* Provided by em28xx-input.c */
299
300void em28xx_set_ir(struct em28xx * dev,struct IR_i2c *ir);
301
302/* Provided by em28xx-core.c */ 335/* Provided by em28xx-core.c */
303 336
304u32 em28xx_request_buffers(struct em28xx *dev, u32 count); 337u32 em28xx_request_buffers(struct em28xx *dev, u32 count);
@@ -314,8 +347,9 @@ int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf,
314int em28xx_write_regs(struct em28xx *dev, u16 reg, char *buf, int len); 347int em28xx_write_regs(struct em28xx *dev, u16 reg, char *buf, int len);
315int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val, 348int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val,
316 u8 bitmask); 349 u8 bitmask);
317int em28xx_write_ac97(struct em28xx *dev, u8 reg, u8 * val); 350int em28xx_set_audio_source(struct em28xx *dev);
318int em28xx_audio_analog_set(struct em28xx *dev); 351int em28xx_audio_analog_set(struct em28xx *dev);
352
319int em28xx_colorlevels_set_default(struct em28xx *dev); 353int em28xx_colorlevels_set_default(struct em28xx *dev);
320int em28xx_capture_start(struct em28xx *dev, int start); 354int em28xx_capture_start(struct em28xx *dev, int start);
321int em28xx_outfmt_set_yuv422(struct em28xx *dev); 355int em28xx_outfmt_set_yuv422(struct em28xx *dev);
@@ -324,6 +358,10 @@ int em28xx_init_isoc(struct em28xx *dev);
324void em28xx_uninit_isoc(struct em28xx *dev); 358void em28xx_uninit_isoc(struct em28xx *dev);
325int em28xx_set_alternate(struct em28xx *dev); 359int em28xx_set_alternate(struct em28xx *dev);
326 360
361/* Provided by em28xx-video.c */
362int em28xx_register_extension(struct em28xx_ops *dev);
363void em28xx_unregister_extension(struct em28xx_ops *dev);
364
327/* Provided by em28xx-cards.c */ 365/* Provided by em28xx-cards.c */
328extern int em2800_variant_detect(struct usb_device* udev,int model); 366extern int em2800_variant_detect(struct usb_device* udev,int model);
329extern void em28xx_pre_card_setup(struct em28xx *dev); 367extern void em28xx_pre_card_setup(struct em28xx *dev);
@@ -331,8 +369,20 @@ extern void em28xx_card_setup(struct em28xx *dev);
331extern struct em28xx_board em28xx_boards[]; 369extern struct em28xx_board em28xx_boards[];
332extern struct usb_device_id em28xx_id_table[]; 370extern struct usb_device_id em28xx_id_table[];
333extern const unsigned int em28xx_bcount; 371extern const unsigned int em28xx_bcount;
372void em28xx_set_ir(struct em28xx *dev, struct IR_i2c *ir);
373
374/* Provided by em28xx-input.c */
375/* TODO: Check if the standard get_key handlers on ir-common can be used */
376int em28xx_get_key_terratec(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw);
377int em28xx_get_key_em_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw);
378int em28xx_get_key_pinnacle_usb_grey(struct IR_i2c *ir, u32 *ir_key,
379 u32 *ir_raw);
380
381/* em2800 registers */
382#define EM2800_AUDIOSRC_REG 0x08
334 383
335/* em28xx registers */ 384/* em28xx registers */
385#define I2C_CLK_REG 0x06
336#define CHIPID_REG 0x0a 386#define CHIPID_REG 0x0a
337#define USBSUSP_REG 0x0c /* */ 387#define USBSUSP_REG 0x0c /* */
338 388
@@ -384,9 +434,12 @@ extern const unsigned int em28xx_bcount;
384 434
385/* em202 registers */ 435/* em202 registers */
386#define MASTER_AC97 0x02 436#define MASTER_AC97 0x02
437#define LINE_IN_AC97 0x10
387#define VIDEO_AC97 0x14 438#define VIDEO_AC97 0x14
388 439
389/* register settings */ 440/* register settings */
441#define EM2800_AUDIO_SRC_TUNER 0x0d
442#define EM2800_AUDIO_SRC_LINE 0x0c
390#define EM28XX_AUDIO_SRC_TUNER 0xc0 443#define EM28XX_AUDIO_SRC_TUNER 0xc0
391#define EM28XX_AUDIO_SRC_LINE 0x80 444#define EM28XX_AUDIO_SRC_LINE 0x80
392 445
@@ -406,22 +459,6 @@ extern const unsigned int em28xx_bcount;
406 printk(KERN_WARNING "%s: "fmt,\ 459 printk(KERN_WARNING "%s: "fmt,\
407 dev->name , ##arg); } while (0) 460 dev->name , ##arg); } while (0)
408 461
409inline static int em28xx_audio_source(struct em28xx *dev, int input)
410{
411 return em28xx_write_reg_bits(dev, AUDIOSRC_REG, input, 0xc0);
412}
413
414inline static int em28xx_audio_usb_mute(struct em28xx *dev, int mute)
415{
416 return em28xx_write_reg_bits(dev, XCLK_REG, mute ? 0x00 : 0x80, 0x80);
417}
418
419inline static int em28xx_audio_analog_setup(struct em28xx *dev)
420{
421 /* unmute video mixer with default volume level */
422 return em28xx_write_ac97(dev, VIDEO_AC97, "\x08\x08");
423}
424
425inline static int em28xx_compression_disable(struct em28xx *dev) 462inline static int em28xx_compression_disable(struct em28xx *dev)
426{ 463{
427 /* side effect of disabling scaler and mixer */ 464 /* side effect of disabling scaler and mixer */
@@ -497,18 +534,17 @@ inline static int em28xx_gamma_set(struct em28xx *dev, s32 val)
497/*FIXME: maxw should be dependent of alt mode */ 534/*FIXME: maxw should be dependent of alt mode */
498inline static unsigned int norm_maxw(struct em28xx *dev) 535inline static unsigned int norm_maxw(struct em28xx *dev)
499{ 536{
500 switch(dev->model){ 537 if (dev->max_range_640_480)
501 case (EM2820_BOARD_MSI_VOX_USB_2): return(640); 538 return 640;
502 default: return(720); 539 else
503 } 540 return 720;
504} 541}
505 542
506inline static unsigned int norm_maxh(struct em28xx *dev) 543inline static unsigned int norm_maxh(struct em28xx *dev)
507{ 544{
508 switch(dev->model){ 545 if (dev->max_range_640_480)
509 case (EM2820_BOARD_MSI_VOX_USB_2): return(480); 546 return 480;
510 default: return (dev->tvnorm->id & V4L2_STD_625_50) ? 576 : 480; 547 else
511 } 548 return (dev->norm & V4L2_STD_625_50) ? 576 : 480;
512} 549}
513
514#endif 550#endif