diff options
Diffstat (limited to 'drivers/media/video/au0828')
-rw-r--r-- | drivers/media/video/au0828/Kconfig | 1 | ||||
-rw-r--r-- | drivers/media/video/au0828/au0828-cards.c | 19 | ||||
-rw-r--r-- | drivers/media/video/au0828/au0828-core.c | 9 | ||||
-rw-r--r-- | drivers/media/video/au0828/au0828-i2c.c | 72 | ||||
-rw-r--r-- | drivers/media/video/au0828/au0828-reg.h | 35 | ||||
-rw-r--r-- | drivers/media/video/au0828/au0828-video.c | 12 | ||||
-rw-r--r-- | drivers/media/video/au0828/au0828.h | 1 |
7 files changed, 91 insertions, 58 deletions
diff --git a/drivers/media/video/au0828/Kconfig b/drivers/media/video/au0828/Kconfig index 05cdf49..0c3a5ba 100644 --- a/drivers/media/video/au0828/Kconfig +++ b/drivers/media/video/au0828/Kconfig @@ -4,6 +4,7 @@ config VIDEO_AU0828 depends on I2C && INPUT && DVB_CORE && USB && VIDEO_V4L2 select I2C_ALGOBIT select VIDEO_TVEEPROM + select VIDEOBUF_VMALLOC select DVB_AU8522 if !DVB_FE_CUSTOMISE select MEDIA_TUNER_XC5000 if !MEDIA_TUNER_CUSTOMISE select MEDIA_TUNER_MXL5007T if !MEDIA_TUNER_CUSTOMISE diff --git a/drivers/media/video/au0828/au0828-cards.c b/drivers/media/video/au0828/au0828-cards.c index 1aabaa7..053bbe8 100644 --- a/drivers/media/video/au0828/au0828-cards.c +++ b/drivers/media/video/au0828/au0828-cards.c @@ -46,6 +46,7 @@ struct au0828_board au0828_boards[] = { .name = "Hauppauge HVR850", .tuner_type = TUNER_XC5000, .tuner_addr = 0x61, + .i2c_clk_divider = AU0828_I2C_CLK_30KHZ, .input = { { .type = AU0828_VMUX_TELEVISION, @@ -70,6 +71,13 @@ struct au0828_board au0828_boards[] = { .name = "Hauppauge HVR950Q", .tuner_type = TUNER_XC5000, .tuner_addr = 0x61, + /* The au0828 hardware i2c implementation does not properly + support the xc5000's i2c clock stretching. So we need to + lower the clock frequency enough where the 15us clock + stretch fits inside of a normal clock cycle, or else the + au0828 fails to set the STOP bit. A 30 KHz clock puts the + clock pulse width at 18us */ + .i2c_clk_divider = AU0828_I2C_CLK_30KHZ, .input = { { .type = AU0828_VMUX_TELEVISION, @@ -94,16 +102,19 @@ struct au0828_board au0828_boards[] = { .name = "Hauppauge HVR950Q rev xxF8", .tuner_type = UNSET, .tuner_addr = ADDR_UNSET, + .i2c_clk_divider = AU0828_I2C_CLK_250KHZ, }, [AU0828_BOARD_DVICO_FUSIONHDTV7] = { .name = "DViCO FusionHDTV USB", .tuner_type = UNSET, .tuner_addr = ADDR_UNSET, + .i2c_clk_divider = AU0828_I2C_CLK_250KHZ, }, [AU0828_BOARD_HAUPPAUGE_WOODBURY] = { .name = "Hauppauge Woodbury", .tuner_type = UNSET, .tuner_addr = ADDR_UNSET, + .i2c_clk_divider = AU0828_I2C_CLK_250KHZ, }, }; @@ -200,8 +211,8 @@ void au0828_card_setup(struct au0828_dev *dev) /* Load the analog demodulator driver (note this would need to be abstracted out if we ever need to support a different demod) */ - sd = v4l2_i2c_new_subdev(&dev->i2c_adap, "au8522", "au8522", - 0x8e >> 1); + sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap, + "au8522", "au8522", 0x8e >> 1); if (sd == NULL) printk(KERN_ERR "analog subdev registration failed\n"); } @@ -209,8 +220,8 @@ void au0828_card_setup(struct au0828_dev *dev) /* Setup tuners */ if (dev->board.tuner_type != TUNER_ABSENT) { /* Load the tuner module, which does the attach */ - sd = v4l2_i2c_new_subdev(&dev->i2c_adap, "tuner", "tuner", - dev->board.tuner_addr); + sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap, + "tuner", "tuner", dev->board.tuner_addr); if (sd == NULL) printk(KERN_ERR "tuner subdev registration fail\n"); diff --git a/drivers/media/video/au0828/au0828-core.c b/drivers/media/video/au0828/au0828-core.c index 8c761d164..4cee0b9 100644 --- a/drivers/media/video/au0828/au0828-core.c +++ b/drivers/media/video/au0828/au0828-core.c @@ -36,8 +36,6 @@ int au0828_debug; module_param_named(debug, au0828_debug, int, 0644); MODULE_PARM_DESC(debug, "enable debug messages"); -static atomic_t au0828_instance = ATOMIC_INIT(0); - #define _AU0828_BULKPIPE 0x03 #define _BULKPIPESIZE 0xffff @@ -169,7 +167,7 @@ static void au0828_usb_disconnect(struct usb_interface *interface) static int au0828_usb_probe(struct usb_interface *interface, const struct usb_device_id *id) { - int ifnum, retval, i; + int ifnum, retval; struct au0828_dev *dev; struct usb_device *usbdev = interface_to_usbdev(interface); @@ -197,10 +195,7 @@ static int au0828_usb_probe(struct usb_interface *interface, usb_set_intfdata(interface, dev); /* Create the v4l2_device */ - i = atomic_inc_return(&au0828_instance) - 1; - snprintf(dev->v4l2_dev.name, sizeof(dev->v4l2_dev.name), "%s-%03d", - "au0828", i); - retval = v4l2_device_register(&dev->usbdev->dev, &dev->v4l2_dev); + retval = v4l2_device_register(&interface->dev, &dev->v4l2_dev); if (retval) { printk(KERN_ERR "%s() v4l2_device_register failed\n", __func__); diff --git a/drivers/media/video/au0828/au0828-i2c.c b/drivers/media/video/au0828/au0828-i2c.c index f9a958d..13e4943 100644 --- a/drivers/media/video/au0828/au0828-i2c.c +++ b/drivers/media/video/au0828/au0828-i2c.c @@ -39,13 +39,15 @@ MODULE_PARM_DESC(i2c_scan, "scan i2c bus at insmod time"); static inline int i2c_slave_did_write_ack(struct i2c_adapter *i2c_adap) { struct au0828_dev *dev = i2c_adap->algo_data; - return au0828_read(dev, REG_201) & 0x08 ? 0 : 1; + return au0828_read(dev, AU0828_I2C_STATUS_201) & + AU0828_I2C_STATUS_NO_WRITE_ACK ? 0 : 1; } static inline int i2c_slave_did_read_ack(struct i2c_adapter *i2c_adap) { struct au0828_dev *dev = i2c_adap->algo_data; - return au0828_read(dev, REG_201) & 0x02 ? 0 : 1; + return au0828_read(dev, AU0828_I2C_STATUS_201) & + AU0828_I2C_STATUS_NO_READ_ACK ? 0 : 1; } static int i2c_wait_read_ack(struct i2c_adapter *i2c_adap) @@ -67,7 +69,8 @@ static int i2c_wait_read_ack(struct i2c_adapter *i2c_adap) static inline int i2c_is_read_busy(struct i2c_adapter *i2c_adap) { struct au0828_dev *dev = i2c_adap->algo_data; - return au0828_read(dev, REG_201) & 0x01 ? 0 : 1; + return au0828_read(dev, AU0828_I2C_STATUS_201) & + AU0828_I2C_STATUS_READ_DONE ? 0 : 1; } static int i2c_wait_read_done(struct i2c_adapter *i2c_adap) @@ -89,7 +92,8 @@ static int i2c_wait_read_done(struct i2c_adapter *i2c_adap) static inline int i2c_is_write_done(struct i2c_adapter *i2c_adap) { struct au0828_dev *dev = i2c_adap->algo_data; - return au0828_read(dev, REG_201) & 0x04 ? 1 : 0; + return au0828_read(dev, AU0828_I2C_STATUS_201) & + AU0828_I2C_STATUS_WRITE_DONE ? 1 : 0; } static int i2c_wait_write_done(struct i2c_adapter *i2c_adap) @@ -111,7 +115,8 @@ static int i2c_wait_write_done(struct i2c_adapter *i2c_adap) static inline int i2c_is_busy(struct i2c_adapter *i2c_adap) { struct au0828_dev *dev = i2c_adap->algo_data; - return au0828_read(dev, REG_201) & 0x10 ? 1 : 0; + return au0828_read(dev, AU0828_I2C_STATUS_201) & + AU0828_I2C_STATUS_BUSY ? 1 : 0; } static int i2c_wait_done(struct i2c_adapter *i2c_adap) @@ -139,19 +144,14 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, dprintk(4, "%s()\n", __func__); - au0828_write(dev, REG_2FF, 0x01); + au0828_write(dev, AU0828_I2C_MULTIBYTE_MODE_2FF, 0x01); - /* FIXME: There is a problem with i2c communications with xc5000 that - requires us to slow down the i2c clock until we have a better - strategy (such as using the secondary i2c bus to do firmware - loading */ - if ((msg->addr << 1) == 0xc2) - au0828_write(dev, REG_202, 0x40); - else - au0828_write(dev, REG_202, 0x07); + /* Set the I2C clock */ + au0828_write(dev, AU0828_I2C_CLK_DIVIDER_202, + dev->board.i2c_clk_divider); /* Hardware needs 8 bit addresses */ - au0828_write(dev, REG_203, msg->addr << 1); + au0828_write(dev, AU0828_I2C_DEST_ADDR_203, msg->addr << 1); dprintk(4, "SEND: %02x\n", msg->addr); @@ -163,7 +163,9 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, actual bytes to the bus, just do a read check. This is consistent with how I saw i2c device checking done in the USB trace of the Windows driver */ - au0828_write(dev, REG_200, 0x20); + au0828_write(dev, AU0828_I2C_TRIGGER_200, + AU0828_I2C_TRIGGER_READ); + if (!i2c_wait_done(i2c_adap)) return -EIO; @@ -177,7 +179,7 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, dprintk(4, " %02x\n", msg->buf[i]); - au0828_write(dev, REG_205, msg->buf[i]); + au0828_write(dev, AU0828_I2C_WRITE_FIFO_205, msg->buf[i]); strobe++; i++; @@ -186,9 +188,12 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, /* Strobe the byte into the bus */ if (i < msg->len) - au0828_write(dev, REG_200, 0x41); + au0828_write(dev, AU0828_I2C_TRIGGER_200, + AU0828_I2C_TRIGGER_WRITE | + AU0828_I2C_TRIGGER_HOLD); else - au0828_write(dev, REG_200, 0x01); + au0828_write(dev, AU0828_I2C_TRIGGER_200, + AU0828_I2C_TRIGGER_WRITE); /* Reset strobe trigger */ strobe = 0; @@ -216,25 +221,22 @@ static int i2c_readbytes(struct i2c_adapter *i2c_adap, dprintk(4, "%s()\n", __func__); - au0828_write(dev, REG_2FF, 0x01); + au0828_write(dev, AU0828_I2C_MULTIBYTE_MODE_2FF, 0x01); - /* FIXME: There is a problem with i2c communications with xc5000 that - requires us to slow down the i2c clock until we have a better - strategy (such as using the secondary i2c bus to do firmware - loading */ - if ((msg->addr << 1) == 0xc2) - au0828_write(dev, REG_202, 0x40); - else - au0828_write(dev, REG_202, 0x07); + /* Set the I2C clock */ + au0828_write(dev, AU0828_I2C_CLK_DIVIDER_202, + dev->board.i2c_clk_divider); /* Hardware needs 8 bit addresses */ - au0828_write(dev, REG_203, msg->addr << 1); + au0828_write(dev, AU0828_I2C_DEST_ADDR_203, msg->addr << 1); dprintk(4, " RECV:\n"); /* Deal with i2c_scan */ if (msg->len == 0) { - au0828_write(dev, REG_200, 0x20); + au0828_write(dev, AU0828_I2C_TRIGGER_200, + AU0828_I2C_TRIGGER_READ); + if (i2c_wait_read_ack(i2c_adap)) return -EIO; return 0; @@ -245,14 +247,18 @@ static int i2c_readbytes(struct i2c_adapter *i2c_adap, i++; if (i < msg->len) - au0828_write(dev, REG_200, 0x60); + au0828_write(dev, AU0828_I2C_TRIGGER_200, + AU0828_I2C_TRIGGER_READ | + AU0828_I2C_TRIGGER_HOLD); else - au0828_write(dev, REG_200, 0x20); + au0828_write(dev, AU0828_I2C_TRIGGER_200, + AU0828_I2C_TRIGGER_READ); if (!i2c_wait_read_done(i2c_adap)) return -EIO; - msg->buf[i-1] = au0828_read(dev, REG_209) & 0xff; + msg->buf[i-1] = au0828_read(dev, AU0828_I2C_READ_FIFO_209) & + 0xff; dprintk(4, " %02x\n", msg->buf[i-1]); } diff --git a/drivers/media/video/au0828/au0828-reg.h b/drivers/media/video/au0828/au0828-reg.h index b15e4a3..c39f3d2 100644 --- a/drivers/media/video/au0828/au0828-reg.h +++ b/drivers/media/video/au0828/au0828-reg.h @@ -30,15 +30,36 @@ #define AU0828_SENSORCTRL_100 0x100 #define AU0828_SENSORCTRL_VBI_103 0x103 -#define REG_200 0x200 -#define REG_201 0x201 -#define REG_202 0x202 -#define REG_203 0x203 -#define REG_205 0x205 -#define REG_209 0x209 -#define REG_2FF 0x2ff +/* I2C registers */ +#define AU0828_I2C_TRIGGER_200 0x200 +#define AU0828_I2C_STATUS_201 0x201 +#define AU0828_I2C_CLK_DIVIDER_202 0x202 +#define AU0828_I2C_DEST_ADDR_203 0x203 +#define AU0828_I2C_WRITE_FIFO_205 0x205 +#define AU0828_I2C_READ_FIFO_209 0x209 +#define AU0828_I2C_MULTIBYTE_MODE_2FF 0x2ff /* Audio registers */ #define AU0828_AUDIOCTRL_50C 0x50C #define REG_600 0x600 + +/*********************************************************************/ +/* Here are constants for values associated with the above registers */ + +/* I2C Trigger (Reg 0x200) */ +#define AU0828_I2C_TRIGGER_WRITE 0x01 +#define AU0828_I2C_TRIGGER_READ 0x20 +#define AU0828_I2C_TRIGGER_HOLD 0x40 + +/* I2C Status (Reg 0x201) */ +#define AU0828_I2C_STATUS_READ_DONE 0x01 +#define AU0828_I2C_STATUS_NO_READ_ACK 0x02 +#define AU0828_I2C_STATUS_WRITE_DONE 0x04 +#define AU0828_I2C_STATUS_NO_WRITE_ACK 0x08 +#define AU0828_I2C_STATUS_BUSY 0x10 + +/* I2C Clock Divider (Reg 0x202) */ +#define AU0828_I2C_CLK_250KHZ 0x07 +#define AU0828_I2C_CLK_100KHZ 0x14 +#define AU0828_I2C_CLK_30KHZ 0x40 diff --git a/drivers/media/video/au0828/au0828-video.c b/drivers/media/video/au0828/au0828-video.c index f7ad495..27bedc6 100644 --- a/drivers/media/video/au0828/au0828-video.c +++ b/drivers/media/video/au0828/au0828-video.c @@ -1100,7 +1100,7 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id * norm) have to make the au0828 bridge adjust the size of its capture buffer, which is currently hardcoded at 720x480 */ - v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_std, *norm); + v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_std, *norm); return 0; } @@ -1154,7 +1154,6 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int index) struct au0828_fh *fh = priv; struct au0828_dev *dev = fh->dev; int i; - struct v4l2_routing route; dprintk(1, "VIDIOC_S_INPUT in function %s, input=%d\n", __func__, index); @@ -1180,9 +1179,8 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int index) break; } - route.input = AUVI_INPUT(index).vmux; - route.output = 0; - v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_routing, &route); + v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_routing, + AUVI_INPUT(index).vmux, 0, 0); for (i = 0; i < AU0828_MAX_INPUT; i++) { int enable = 0; @@ -1205,8 +1203,8 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int index) } } - route.input = AUVI_INPUT(index).amux; - v4l2_device_call_all(&dev->v4l2_dev, 0, audio, s_routing, &route); + v4l2_device_call_all(&dev->v4l2_dev, 0, audio, s_routing, + AUVI_INPUT(index).amux, 0, 0); return 0; } diff --git a/drivers/media/video/au0828/au0828.h b/drivers/media/video/au0828/au0828.h index 6ed1a61..b977915 100644 --- a/drivers/media/video/au0828/au0828.h +++ b/drivers/media/video/au0828/au0828.h @@ -81,6 +81,7 @@ struct au0828_board { char *name; unsigned int tuner_type; unsigned char tuner_addr; + unsigned char i2c_clk_divider; struct au0828_input input[AU0828_MAX_INPUT]; }; |