v4l: saa7134 update
PATCH 4/6 v4l: saa7134 update
This is a update for the saa7134 driver, changes:
* adapt to the video-buf changes.
* add new cards.
* split mpeg encoder card support to separare module (saa7134-empress), as preparation for the dvb support which also uses the MPEG capabilities of the card.
* started working on dvb support (not functional yet, also marked 'BROKEN').
* convert insmod options to new-style.
The patch also removes all trailing whitespaces. I've a script to remove them from my sources now, that should kill those no-op whitespace changes in my patches after merging this initial cleanup.
--- drivers/media/video/Kconfig | 7 drivers/media/video/saa7134/Makefile | 6 drivers/media/video/saa7134/saa6752hs.c | 94 ++-- drivers/media/video/saa7134/saa7134-cards.c | 124 +++++ drivers/media/video/saa7134/saa7134-core.c | 253 +++++++---- drivers/media/video/saa7134/saa7134-dvb.c | 91 ++++ drivers/media/video/saa7134/saa7134-empress.c | 394 ++++++++++++++++++ drivers/media/video/saa7134/saa7134-i2c.c | 32 + drivers/media/video/saa7134/saa7134-input.c | 13 drivers/media/video/saa7134/saa7134-oss.c | 26 - drivers/media/video/saa7134/saa7134-ts.c | 365 +--------------- drivers/media/video/saa7134/saa7134-tvaudio.c | 47 +- drivers/media/video/saa7134/saa7134-vbi.c | 37 - drivers/media/video/saa7134/saa7134-video.c | 148 +++--- drivers/media/video/saa7134/saa7134.h | 83 ++- include/media/saa6752hs.h | 6 16 files changed, 1073 insertions(+), 653 deletions(-)
drivers/media/video/saa7134/saa7134.h +59 -24
@@ -1,5 +1,5 @@/* -* $Id: saa7134.h,v 1.20 2004/09/30 12:21:15 kraxel Exp $ +* $Id: saa7134.h,v 1.27 2004/11/04 11:03:52 kraxel Exp $ * * v4l2 device driver for philips saa7134 based TV cards *
@@ -31,11 +31,12 @@#include <asm/io.h> -#include <media/video-buf.h> #include <media/tuner.h> #include <media/audiochip.h> #include <media/id.h> #include <media/ir-common.h> +#include <media/video-buf.h> +#include <media/video-buf-dvb.h> #ifndef TRUE # define TRUE (1==1)
@@ -164,8 +165,12 @@ struct saa7134_format {#define SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUS 41#define SAA7134_BOARD_SABRENT_SBTTVFM 42#define SAA7134_BOARD_ZOLID_XPERT_TV7134 43 -#define SAA7134_EMPIRE_PCI_TV_RADIO_LE 44 +#define SAA7134_BOARD_EMPIRE_PCI_TV_RADIO_LE 44 +#define SAA7134_BOARD_AVERMEDIA_307 45 +#define SAA7134_BOARD_AVERMEDIA_CARDBUS 46 +#define SAA7134_BOARD_CINERGY400_CARDBUS 47 +#define SAA7134_MAXBOARDS 8#define SAA7134_INPUT_MAX 8struct saa7134_input {
@@ -176,6 +181,12 @@ struct saa7134_input { unsigned int tv:1; }; +enum saa7134_mpeg_type { +SAA7134_MPEG_UNUSED , +SAA7134_MPEG_EMPRESS , +SAA7134_MPEG_DVB , +}; +struct saa7134_board {char *name;unsigned int audio_clock;
@@ -185,18 +196,20 @@ struct saa7134_board {struct saa7134_input inputs[SAA7134_INPUT_MAX ];struct saa7134_input radio;struct saa7134_input mute; - -/* peripheral I/O */ -unsigned int has_ts; -enum saa7134_video_out video_out;/* i2c chip info */ unsigned int tuner_type;unsigned int tda9887_conf; + +/* peripheral I/O */ +enum saa7134_video_out video_out; +enum saa7134_mpeg_type mpeg; };#define card_has_radio (dev) (NULL != saa7134_boards[dev->board].radio.name) -#define card_has_ts (dev) (saa7134_boards[dev->board].has_ts) +#define card_is_empress (dev) (SAA7134_MPEG_EMPRESS == saa7134_boards[dev->board].mpeg) +#define card_is_dvb (dev) (SAA7134_MPEG_DVB == saa7134_boards[dev->board].mpeg) +#define card_has_mpeg (dev) (SAA7134_MPEG_UNUSED != saa7134_boards[dev->board].mpeg)#define card (dev) (saa7134_boards[dev->board])#define card_in (dev,n) (saa7134_boards[dev->board].inputs[n])
@@ -264,7 +277,7 @@ struct saa7134_fh {unsigned int radio;enum v4l2_buf_type type;unsigned int resources; -#ifdef VIDIOC_G_PRIORITY +#ifdef VIDIOC_G_PRIORITY enum v4l2_priority prio;#endif
@@ -284,16 +297,6 @@ struct saa7134_fh {struct saa7134_pgtable pt_vbi; }; -/* TS status */ -struct saa7134_ts { -unsigned int users; - -/* TS capture */ -struct videobuf_queue ts; -struct saa7134_pgtable pt_ts; -int started; -}; -/* oss dsp status */ struct saa7134_oss {struct semaphore lock;
@@ -338,23 +341,37 @@ struct saa7134_ir {struct timer_list timer; }; +/* ts/mpeg status */ +struct saa7134_ts { +/* TS capture */ +struct saa7134_pgtable pt_ts; +int nr_packets; +int nr_bufs; +}; + +/* ts/mpeg ops */ +struct saa7134_mpeg_ops { +enum saa7134_mpeg_type type; +struct list_head next; +int (*init)(struct saa7134_dev *dev); +int (*fini)(struct saa7134_dev *dev); +}; +/* global device status */ struct saa7134_dev {struct list_head devlist;struct semaphore lock;spinlock_t slock; -#ifdef VIDIOC_G_PRIORITY +#ifdef VIDIOC_G_PRIORITY struct v4l2_prio_state prio;#endif /* various device info */ unsigned int resources;struct video_device *video_dev; -struct video_device *ts_dev;struct video_device *radio_dev;struct video_device *vbi_dev;struct saa7134_oss oss; -struct saa7134_ts ts;/* infrared remote */ int has_remote;
@@ -362,6 +379,7 @@ struct saa7134_dev {/* pci i/o */ char name[32 ]; +int nr;struct pci_dev *pci;unsigned char pci_rev,pci_lat;__u32 *lmmio;
@@ -386,7 +404,6 @@ struct saa7134_dev {/* video+ts+vbi capture */ struct saa7134_dmaqueue video_q; -struct saa7134_dmaqueue ts_q;struct saa7134_dmaqueue vbi_q;unsigned int video_fieldcount;unsigned int vbi_fieldcount;
@@ -420,6 +437,19 @@ struct saa7134_dev {struct saa7134_input *hw_input;unsigned int hw_mute;int last_carrier; + +/* SAA7134_MPEG_* */ +struct saa7134_ts ts; +struct saa7134_dmaqueue ts_q; +struct saa7134_mpeg_ops *mops; + +/* SAA7134_MPEG_EMPRESS only */ +struct video_device *empress_dev; +struct videobuf_queue empress_tsq; +unsigned int empress_users; + +/* SAA7134_MPEG_DVB only */ +struct videobuf_dvb dvb; };/* ----------------------------------------------------------- */
@@ -512,11 +542,16 @@ void saa7134_irq_video_done(struct saa71/* ----------------------------------------------------------- */ /* saa7134-ts.c */ -extern struct video_device saa7134_ts_template; +#define TS_PACKET_SIZE 188/* TS packets 188 bytes */ + +extern struct videobuf_queue_ops saa7134_ts_qops; +int saa7134_ts_init1 (struct saa7134_dev *dev);int saa7134_ts_fini (struct saa7134_dev *dev);void saa7134_irq_ts_done (struct saa7134_dev *dev,unsigned long status); +int saa7134_ts_register (struct saa7134_mpeg_ops *ops); +void saa7134_ts_unregister (struct saa7134_mpeg_ops *ops);/* ----------------------------------------------------------- */ /* saa7134-vbi.c */
drivers/media/video/saa7134/saa7134-core.c +158 -95
473 lines not on this page · raw message
drivers/media/video/saa7134/saa7134-cards.c +113 -11
224 lines not on this page · raw message
drivers/media/video/saa7134/saa7134-i2c.c +22 -10
@@ -1,5 +1,5 @@/* -* $Id: saa7134-i2c.c,v 1.5 2004/10/06 17:30:51 kraxel Exp $ +* $Id: saa7134-i2c.c,v 1.7 2004/11/07 13:17:15 kraxel Exp $ * * device driver for philips saa7134 based TV cards * i2c interface support
@@ -34,11 +34,11 @@/* ----------------------------------------------------------- */ static unsigned int i2c_debug =0 ; -MODULE_PARM (i2c_debug,"i" ); +module_param (i2c_debug, int,0644 );MODULE_PARM_DESC (i2c_debug,"enable debug messages [i2c]" );static unsigned int i2c_scan =0 ; -MODULE_PARM (i2c_scan,"i" ); +module_param (i2c_scan, int,0444 );MODULE_PARM_DESC (i2c_scan,"scan i2c bus at insmod time" );#define d1printk if (1 == i2c_debug) printk
@@ -88,7 +88,7 @@ enum i2c_attr {static inline enum i2c_status i2c_get_status (struct saa7134_dev *dev) {enum i2c_status status; - + status =saa_readb (SAA7134_I2C_ATTR_STATUS ) &0x0f ;d2printk (KERN_DEBUG "%s: i2c stat <= %s\n" ,dev->name, str_i2c_status[status]);
@@ -184,7 +184,7 @@ static int i2c_reset(struct saa7134_devif (!i2c_is_idle (status))return FALSE; - +i2c_set_attr (dev,NOP );return TRUE; }
@@ -210,7 +210,7 @@ static inline int i2c_send_byte(struct ssaa_writel (SAA7134_I2C_ATTR_STATUS >>2 , dword);#endif d2printk (KERN_DEBUG "%s: i2c data => 0x%x\n" ,dev->name,data); - +if (!i2c_is_busy_wait (dev))return -EIO ; status =i2c_get_status (dev);
@@ -223,7 +223,7 @@ static inline int i2c_recv_byte(struct s {enum i2c_status status;unsigned char data; - +i2c_set_attr (dev,CONTINUE );if (!i2c_is_busy_wait (dev))return -EIO ;
@@ -302,7 +302,7 @@ static int saa7134_i2c_xfer(struct i2c_a/* ----------------------------------------------------------- */ -static int algo_control (struct i2c_adapter *adapter, +static int algo_control (struct i2c_adapter *adapter,unsigned int cmd,unsigned long arg) {return 0 ;
@@ -313,6 +313,18 @@ static u32 functionality(struct i2c_adapreturn I2C_FUNC_SMBUS_EMUL ; } +#ifndef I2C_PEC +static void inc_use (struct i2c_adapter *adap) +{ +MOD_INC_USE_COUNT ; +} + +static void dec_use (struct i2c_adapter *adap) +{ +MOD_DEC_USE_COUNT ; +} +#endif +static int attach_inform (struct i2c_client *client) {struct saa7134_dev *dev = client->adapter->algo_data;
@@ -419,10 +431,10 @@ int saa7134_i2c_register(struct saa7134_strcpy (dev->i2c_adap.name,dev->name); dev->i2c_adap.algo_data = dev;i2c_add_adapter (&dev->i2c_adap); - + dev->i2c_client = saa7134_client_template; dev->i2c_client.adapter = &dev->i2c_adap; - +saa7134_i2c_eeprom (dev,dev->eedata,sizeof (dev->eedata));if (i2c_scan)do_i2c_scan (dev->name,&dev->i2c_client);
drivers/media/video/saa7134/saa7134-tvaudio.c +27 -20
132 lines not on this page · raw message
drivers/media/video/saa7134/saa7134-video.c +70 -78
490 lines not on this page · raw message
drivers/media/video/saa7134/saa7134-vbi.c +19 -18
@@ -1,5 +1,5 @@/* -* $Id: saa7134-vbi.c,v 1.3 2004/09/23 13:58:19 kraxel Exp $ +* $Id: saa7134-vbi.c,v 1.5 2004/11/07 13:17:15 kraxel Exp $ * * device driver for philips saa7134 based TV cards * video4linux video interface
@@ -33,11 +33,11 @@/* ------------------------------------------------------------------ */ static unsigned int vbi_debug =0 ; -MODULE_PARM (vbi_debug,"i" ); +module_param (vbi_debug, int,0644 );MODULE_PARM_DESC (vbi_debug,"enable debug messages [vbi]" );static unsigned int vbibufs =4 ; -MODULE_PARM (vbibufs,"i" ); +module_param (vbibufs, int,0444 );MODULE_PARM_DESC (vbibufs,"number of vbi buffers, range 2-32" ); #define dprintk(fmt, arg...) if (vbi_debug) \
@@ -53,7 +53,7 @@ static void task_init(struct saa7134_dev int task) {struct saa7134_tvnorm *norm = dev->tvnorm; - +/* setup video scaler */ saa_writeb (SAA7134_VBI_H_START1 (task), norm->h_start &0xff );saa_writeb (SAA7134_VBI_H_START2 (task), norm->h_start >>8 );
@@ -115,12 +115,13 @@ static int buffer_activate(struct saa713return 0 ; } -static int buffer_prepare (void *priv,struct videobuf_buffer *vb, +static int buffer_prepare (struct videobuf_queue *q, +struct videobuf_buffer *vb,enum v4l2_field field) { -struct saa7134_fh *fh = priv; +struct saa7134_fh *fh = q->priv_data;struct saa7134_dev *dev = fh->dev; -struct saa7134_buf *buf = (struct saa7134_buf *)vb; + struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb);struct saa7134_tvnorm *norm = dev->tvnorm;unsigned int lines, llength, size;int err;
@@ -169,12 +170,12 @@ static int buffer_prepare(void *priv, st }static int -buffer_setup (void *priv,unsigned int *count,unsigned int *size) +buffer_setup (struct videobuf_queue *q,unsigned int *count,unsigned int *size) { -struct saa7134_fh *fh = priv; +struct saa7134_fh *fh = q->priv_data;struct saa7134_dev *dev = fh->dev;int llength,lines; - + lines = dev->tvnorm->vbi_v_stop - dev->tvnorm->vbi_v_start +1 ;#if 1 llength =VBI_LINE_LENGTH ;
@@ -190,21 +191,21 @@ buffer_setup(void *priv, unsigned int *creturn 0 ; } -static void buffer_queue (void *priv,struct videobuf_buffer *vb) +static void buffer_queue (struct videobuf_queue *q,struct videobuf_buffer *vb) { -struct saa7134_fh *fh = priv; +struct saa7134_fh *fh = q->priv_data;struct saa7134_dev *dev = fh->dev; -struct saa7134_buf *buf = (struct saa7134_buf *)vb; - + struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb); +saa7134_buffer_queue (dev,&dev->vbi_q,buf); } -static void buffer_release (void *priv,struct videobuf_buffer *vb) +static void buffer_release (struct videobuf_queue *q,struct videobuf_buffer *vb) { -struct saa7134_fh *fh = priv; +struct saa7134_fh *fh = q->priv_data;struct saa7134_dev *dev = fh->dev; -struct saa7134_buf *buf = (struct saa7134_buf *)vb; - + struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb); +saa7134_dma_free (dev,buf); }
drivers/media/video/saa7134/saa7134-oss.c +13 -13
@@ -1,5 +1,5 @@/* -* $Id: saa7134-oss.c,v 1.9 2004/09/15 16:15:24 kraxel Exp $ +* $Id: saa7134-oss.c,v 1.11 2004/11/07 13:17:15 kraxel Exp $ * * device driver for philips saa7134 based TV cards * oss dsp interface
@@ -34,11 +34,11 @@/* ------------------------------------------------------------------ */ static unsigned int oss_debug =0 ; -MODULE_PARM (oss_debug,"i" ); +module_param (oss_debug, int,0644 );MODULE_PARM_DESC (oss_debug,"enable debug messages [oss]" );static unsigned int oss_rate =0 ; -MODULE_PARM (oss_rate,"i" ); +module_param (oss_rate, int,0444 );MODULE_PARM_DESC (oss_rate,"sample rate (valid are: 32000,48000)" ); #define dprintk(fmt, arg...) if (oss_debug) \
@@ -140,7 +140,7 @@ static int dsp_rec_start(struct saa7134_ }switch (dev->oss.afmt) { -case AFMT_S8 : +case AFMT_S8 :case AFMT_S16_LE :case AFMT_S16_BE : sign =1 ;break ;default : sign =0 ;break ;
@@ -161,7 +161,7 @@ static int dsp_rec_start(struct saa7134_if (sign) fmt |=0x04 ; fmt |= (TV == dev->oss.input) ?0xc0 :0x80 ; - +saa_writeb (SAA7134_NUM_SAMPLES0 , (dev->oss.blksize &0x0000ff ));saa_writeb (SAA7134_NUM_SAMPLES1 , (dev->oss.blksize &0x00ff00 ) >>8 );saa_writeb (SAA7134_NUM_SAMPLES2 , (dev->oss.blksize &0xff0000 ) >>16 );
@@ -193,7 +193,7 @@ static int dsp_rec_start(struct saa7134_saa_writel (SAA7134_RS_BA2 (6 ),dev->oss.blksize);saa_writel (SAA7134_RS_PITCH (6 ),0 );saa_writel (SAA7134_RS_CONTROL (6 ),control); - +/* start dma */ dev->oss.recording_on =1 ;spin_lock_irqsave (&dev->slock,flags);
@@ -369,7 +369,7 @@ static int dsp_ioctl(struct inode *inodevoid __user *argp = (void __user *) arg;int __user *p = argp;int val =0 ; - +if (oss_debug >1 )saa7134_print_ioctl (dev->name,cmd);switch (cmd) {
@@ -412,7 +412,7 @@ static int dsp_ioctl(struct inode *inode/* fall through */ case SOUND_PCM_READ_CHANNELS :return put_user (dev->oss.channels, p); - +case SNDCTL_DSP_GETFMTS :/* Returns a mask */ return put_user(AFMT_U8 | AFMT_S8 | AFMT_U16_LE | AFMT_U16_BE |
@@ -535,7 +535,7 @@ static int mixer_recsrc_7134(struct saa7134_dev *dev) {int analog_io,rate; - +switch (dev->oss.input) {case TV :saa_andorb (SAA7134_AUDIO_FORMAT_CTRL ,0xc0 ,0xc0 );
@@ -557,7 +557,7 @@ static int mixer_recsrc_7133(struct saa7134_dev *dev) {u32 value =0xbbbbbb ; - +switch (dev->oss.input) {case TV : value =0xbbbb10 ;/* MAIN */
@@ -655,7 +655,7 @@ static int mixer_ioctl(struct inode *inoint val,ret;void __user *argp = (void __user *) arg;int __user *p = argp; - +if (oss_debug >1 )saa7134_print_ioctl (dev->name,cmd);switch (cmd) {
@@ -786,7 +786,7 @@ int saa7134_oss_init1(struct saa7134_devmixer_level (dev,LINE1 ,dev->oss.line1);mixer_level (dev,LINE2 ,dev->oss.line2);mixer_recsrc (dev, (dev->oss.rate ==32000 ) ?TV :LINE2 ); - +return 0 ; }
@@ -840,7 +840,7 @@ void saa7134_irq_oss_done(struct saa7134 dev->oss.dma_blk = (dev->oss.dma_blk +1 ) % dev->oss.blocks; dev->oss.read_count += dev->oss.blksize;wake_up (&dev->oss.wq); - + done:spin_unlock (&dev->slock); }
drivers/media/video/saa7134/saa7134-ts.c +39 -326
458 lines not on this page · raw message
drivers/media/video/saa7134/saa7134-input.c +7 -6
@@ -1,5 +1,5 @@/* -* $Id: saa7134-input.c,v 1.9 2004/09/15 16:15:24 kraxel Exp $ +* $Id: saa7134-input.c,v 1.12 2004/11/07 13:17:15 kraxel Exp $ * * handle saa7134 IR remotes via linux kernel input layer. *
@@ -30,11 +30,11 @@#include "saa7134.h" static unsigned int disable_ir =0 ; -MODULE_PARM (disable_ir,"i" ); +module_param (disable_ir, int,0444 );MODULE_PARM_DESC (disable_ir,"disable infrared remote support" );static unsigned int ir_debug =0 ; -MODULE_PARM (ir_debug,"i" ); +module_param (ir_debug, int,0644 );MODULE_PARM_DESC (ir_debug,"enable debug messages [IR]" ); #define dprintk(fmt, arg...) if (ir_debug) \
@@ -63,7 +63,7 @@ static IR_KEYTAB_TYPE flyvideo_codes[IR_ [ 20 ] = KEY_VOLUMEUP, [ 23 ] = KEY_VOLUMEDOWN, [ 18 ] = KEY_CHANNELUP, // Channel + - [ 19 ] = KEY_CHANNELDOWN, // Channel - + [ 19 ] = KEY_CHANNELDOWN, // Channel - [ 6 ] = KEY_AGAIN, // Recal [ 16 ] = KEY_KPENTER, // Enter
@@ -353,6 +353,7 @@ int saa7134_input_init1(struct saa7134_d polling =50 ;// ms break ;case SAA7134_BOARD_MD2819 : +case SAA7134_BOARD_AVERMEDIA_307 : ir_codes = md2819_codes; mask_keycode =0x0007C8 ; mask_keydown =0x000010 ;
@@ -378,7 +379,7 @@ int saa7134_input_init1(struct saa7134_d ir->mask_keydown = mask_keydown; ir->mask_keyup = mask_keyup; ir->polling = polling; - +/* init input device */ snprintf (ir->name,sizeof (ir->name),"saa7134 IR (%s)" , saa7134_boards[dev->board].name);
@@ -417,7 +418,7 @@ void saa7134_input_fini(struct saa7134_d {if (NULL == dev->remote)return ; - +input_unregister_device (&dev->remote->dev);if (dev->remote->polling)del_timer_sync (&dev->remote->timer);
drivers/media/video/saa7134/saa7134-empress.c new file +394 -0
394 lines not on this page · raw message
drivers/media/video/saa7134/saa7134-dvb.c new file +91 -0
91 lines not on this page · raw message
include/media/saa6752hs.h +3 -3
@@ -1,4 +1,4 @@ -/* +/* saa6752hs.h - definition for saa6752hs MPEG encoder Copyright (C) 2003 Andrew de Quincey <[email protected]>
@@ -31,14 +31,14 @@ enum mpeg_bitrate_mode {enum mpeg_audio_bitrate {MPEG_AUDIO_BITRATE_256 =0 ,/* 256 kBit/sec */ MPEG_AUDIO_BITRATE_384 =1 ,/* 384 kBit/sec */ - +MPEG_AUDIO_BITRATE_MAX };#define MPEG_VIDEO_TARGET_BITRATE_MAX 27000#define MPEG_VIDEO_MAX_BITRATE_MAX 27000#define MPEG_TOTAL_BITRATE_MAX 27000 - +struct mpeg_params {enum mpeg_bitrate_mode bitrate_mode;unsigned int video_target_bitrate;
drivers/media/video/saa7134/saa6752hs.c +47 -47
209 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
#define printk(args...) fprintf(stderr, ## args)
Part of the diff is not shown here. View the raw message.