The patch number 10729 was added via Hans Verkuil <[email protected]>
to http://linuxtv.org/hg/v4l-dvb master development tree.
Kernel patches in this development tree may be modified to be backward
compatible with older kernels. Compatibility modifications will be
removed before inclusion into the mainstream Kernel
If anyone has any objections, please let us know by sending a message to:
Linux Media Mailing List <[email protected]>
------
From: Hans Verkuil <[email protected]>
zoran: convert to v4l2_device/v4l2_subdev.
Priority: normal
Signed-off-by: Hans Verkuil <[email protected]>
---
linux/drivers/media/video/zoran/zoran.h | 19 +
linux/drivers/media/video/zoran/zoran_card.c | 263 +++++------------
linux/drivers/media/video/zoran/zoran_device.c | 90 ++---
linux/drivers/media/video/zoran/zoran_device.h | 13
linux/drivers/media/video/zoran/zoran_driver.c | 78 +----
5 files changed, 167 insertions(+), 296 deletions(-)
diff -r 7ab48645e84b -r a5c93b7614e4 linux/drivers/media/video/zoran/zoran.h
--- a/linux/drivers/media/video/zoran/zoran.h Thu Feb 19 18:56:37 2009 +0100
+++ b/linux/drivers/media/video/zoran/zoran.h Thu Feb 19 20:18:23 2009 +0100
@@ -30,6 +30,8 @@
#ifndef _BUZ_H_
#define _BUZ_H_
+
+#include <media/v4l2-device.h>
struct zoran_requestbuffers {
unsigned long count; /* Number of buffers for MJPEG grabbing */
@@ -339,7 +341,12 @@ struct card_info {
struct card_info {
enum card_type type;
char name[32];
- u16 i2c_decoder, i2c_encoder; /* I2C types */
+ const char *i2c_decoder; /* i2c decoder device */
+ const char *mod_decoder; /* i2c decoder module */
+ const unsigned short *addrs_decoder;
+ const char *i2c_encoder; /* i2c encoder device */
+ const char *mod_encoder; /* i2c encoder module */
+ const unsigned short *addrs_encoder;
u16 video_vfe, video_codec; /* videocodec types */
u16 audio_chip; /* audio type */
@@ -370,14 +377,15 @@ struct card_info {
};
struct zoran {
+ struct v4l2_device v4l2_dev;
struct video_device *video_dev;
struct i2c_adapter i2c_adapter; /* */
struct i2c_algo_bit_data i2c_algo; /* */
u32 i2cbr;
- struct i2c_client *decoder; /* video decoder i2c client */
- struct i2c_client *encoder; /* video encoder i2c client */
+ struct v4l2_subdev *decoder; /* video decoder sub-device */
+ struct v4l2_subdev *encoder; /* video encoder sub-device */
struct videocodec *codec; /* video codec */
struct videocodec *vfe; /* video front end */
@@ -481,6 +489,11 @@ struct zoran {
wait_queue_head_t test_q;
};
+static inline struct zoran *to_zoran(struct v4l2_device *v4l2_dev)
+{
+ return container_of(v4l2_dev, struct zoran, v4l2_dev);
+}
+
/* There was something called _ALPHA_BUZ that used the PCI address instead of
* the kernel iomapped address for btread/btwrite. */
#define btwrite(dat,adr) writel((dat), zr->zr36057_mem+(adr))
diff -r 7ab48645e84b -r a5c93b7614e4
linux/drivers/media/video/zoran/zoran_card.c
--- a/linux/drivers/media/video/zoran/zoran_card.c Thu Feb 19 18:56:37
2009 +0100
+++ b/linux/drivers/media/video/zoran/zoran_card.c Thu Feb 19 20:18:23
2009 +0100
@@ -333,47 +333,6 @@ avs6eyes_init (struct zoran *zr)
}
static char *
-i2cid_to_modulename (u16 i2c_id)
-{
- char *name = NULL;
-
- switch (i2c_id) {
- case I2C_DRIVERID_SAA7110:
- name = "saa7110";
- break;
- case I2C_DRIVERID_SAA711X:
- name = "saa7115";
- break;
- case I2C_DRIVERID_SAA7185B:
- name = "saa7185";
- break;
- case I2C_DRIVERID_ADV7170:
- name = "adv7170";
- break;
- case I2C_DRIVERID_ADV7175:
- name = "adv7175";
- break;
- case I2C_DRIVERID_BT819:
- name = "bt819";
- break;
- case I2C_DRIVERID_BT856:
- name = "bt856";
- break;
- case I2C_DRIVERID_BT866:
- name = "bt866";
- break;
- case I2C_DRIVERID_VPX3220:
- name = "vpx3220";
- break;
- case I2C_DRIVERID_KS0127:
- name = "ks0127";
- break;
- }
-
- return name;
-}
-
-static char *
codecid_to_modulename (u16 codecid)
{
char *name = NULL;
@@ -423,11 +382,24 @@ static struct tvnorm f50ccir601_avs6eyes
static struct tvnorm f50ccir601_avs6eyes = { 864, 720, 74, 804, 625, 576, 18 };
static struct tvnorm f60ccir601_avs6eyes = { 858, 720, 56, 788, 525, 480, 16 };
+static const unsigned short vpx3220_addrs[] = { 0x43, 0x47, I2C_CLIENT_END };
+static const unsigned short saa7110_addrs[] = { 0x4e, 0x4f, I2C_CLIENT_END };
+static const unsigned short saa7111_addrs[] = { 0x25, 0x24, I2C_CLIENT_END };
+static const unsigned short saa7114_addrs[] = { 0x21, 0x20, I2C_CLIENT_END };
+static const unsigned short adv717x_addrs[] = { 0x6a, 0x6b, 0x2a, 0x2b,
I2C_CLIENT_END };
+static const unsigned short ks0127_addrs[] = { 0x6c, 0x6d, I2C_CLIENT_END };
+static const unsigned short saa7185_addrs[] = { 0x44, I2C_CLIENT_END };
+static const unsigned short bt819_addrs[] = { 0x45, I2C_CLIENT_END };
+static const unsigned short bt856_addrs[] = { 0x44, I2C_CLIENT_END };
+static const unsigned short bt866_addrs[] = { 0x44, I2C_CLIENT_END };
+
static struct card_info zoran_cards[NUM_CARDS] __devinitdata = {
{
.type = DC10_old,
.name = "DC10(old)",
- .i2c_decoder = I2C_DRIVERID_VPX3220,
+ .i2c_decoder = "vpx3220a",
+ .mod_decoder = "vpx3220",
+ .addrs_decoder = vpx3220_addrs,
.video_codec = CODEC_TYPE_ZR36050,
.video_vfe = CODEC_TYPE_ZR36016,
@@ -455,8 +427,12 @@ static struct card_info zoran_cards[NUM_
}, {
.type = DC10_new,
.name = "DC10(new)",
- .i2c_decoder = I2C_DRIVERID_SAA7110,
- .i2c_encoder = I2C_DRIVERID_ADV7175,
+ .i2c_decoder = "saa7110",
+ .mod_decoder = "saa7110",
+ .addrs_decoder = saa7110_addrs,
+ .i2c_encoder = "adv7175",
+ .mod_encoder = "adv7175",
+ .addrs_encoder = adv717x_addrs,
.video_codec = CODEC_TYPE_ZR36060,
.inputs = 3,
@@ -482,8 +458,12 @@ static struct card_info zoran_cards[NUM_
}, {
.type = DC10plus,
.name = "DC10plus",
- .i2c_decoder = I2C_DRIVERID_SAA7110,
- .i2c_encoder = I2C_DRIVERID_ADV7175,
+ .i2c_decoder = "saa7110",
+ .mod_decoder = "saa7110",
+ .addrs_decoder = saa7110_addrs,
+ .i2c_encoder = "adv7175",
+ .mod_encoder = "adv7175",
+ .addrs_encoder = adv717x_addrs,
.video_codec = CODEC_TYPE_ZR36060,
.inputs = 3,
@@ -510,8 +490,12 @@ static struct card_info zoran_cards[NUM_
}, {
.type = DC30,
.name = "DC30",
- .i2c_decoder = I2C_DRIVERID_VPX3220,
- .i2c_encoder = I2C_DRIVERID_ADV7175,
+ .i2c_decoder = "vpx3220a",
+ .mod_decoder = "vpx3220",
+ .addrs_decoder = vpx3220_addrs,
+ .i2c_encoder = "adv7175",
+ .mod_encoder = "adv7175",
+ .addrs_encoder = adv717x_addrs,
.video_codec = CODEC_TYPE_ZR36050,
.video_vfe = CODEC_TYPE_ZR36016,
@@ -539,8 +523,12 @@ static struct card_info zoran_cards[NUM_
}, {
.type = DC30plus,
.name = "DC30plus",
- .i2c_decoder = I2C_DRIVERID_VPX3220,
- .i2c_encoder = I2C_DRIVERID_ADV7175,
+ .i2c_decoder = "vpx3220a",
+ .mod_decoder = "vpx3220",
+ .addrs_decoder = vpx3220_addrs,
+ .i2c_encoder = "adv7175",
+ .mod_encoder = "adv7175",
+ .addrs_encoder = adv717x_addrs,
.video_codec = CODEC_TYPE_ZR36050,
.video_vfe = CODEC_TYPE_ZR36016,
@@ -568,8 +556,12 @@ static struct card_info zoran_cards[NUM_
}, {
.type = LML33,
.name = "LML33",
- .i2c_decoder = I2C_DRIVERID_BT819,
- .i2c_encoder = I2C_DRIVERID_BT856,
+ .i2c_decoder = "bt819a",
+ .mod_decoder = "bt819",
+ .addrs_decoder = bt819_addrs,
+ .i2c_encoder = "bt856",
+ .mod_encoder = "bt856",
+ .addrs_encoder = bt856_addrs,
.video_codec = CODEC_TYPE_ZR36060,
.inputs = 2,
@@ -595,8 +587,12 @@ static struct card_info zoran_cards[NUM_
}, {
.type = LML33R10,
.name = "LML33R10",
- .i2c_decoder = I2C_DRIVERID_SAA711X,
- .i2c_encoder = I2C_DRIVERID_ADV7170,
+ .i2c_decoder = "saa7114",
+ .mod_decoder = "saa7115",
+ .addrs_decoder = saa7114_addrs,
+ .i2c_encoder = "adv7170",
+ .mod_encoder = "adv7170",
+ .addrs_encoder = adv717x_addrs,
.video_codec = CODEC_TYPE_ZR36060,
.inputs = 2,
@@ -622,8 +618,12 @@ static struct card_info zoran_cards[NUM_
}, {
.type = BUZ,
.name = "Buz",
- .i2c_decoder = I2C_DRIVERID_SAA711X,
- .i2c_encoder = I2C_DRIVERID_SAA7185B,
+ .i2c_decoder = "saa7111",
+ .mod_decoder = "saa7115",
+ .addrs_decoder = saa7111_addrs,
+ .i2c_encoder = "saa7185",
+ .mod_encoder = "saa7185",
+ .addrs_encoder = saa7185_addrs,
.video_codec = CODEC_TYPE_ZR36060,
.inputs = 2,
@@ -651,8 +651,12 @@ static struct card_info zoran_cards[NUM_
.name = "6-Eyes",
/* AverMedia chose not to brand the 6-Eyes. Thus it
can't be autodetected, and requires card=x. */
- .i2c_decoder = I2C_DRIVERID_KS0127,
- .i2c_encoder = I2C_DRIVERID_BT866,
+ .i2c_decoder = "ks0127",
+ .mod_decoder = "ks0127",
+ .addrs_decoder = ks0127_addrs,
+ .i2c_encoder = "bt866",
+ .mod_encoder = "bt866",
+ .addrs_encoder = bt866_addrs,
.video_codec = CODEC_TYPE_ZR36060,
.inputs = 10,
@@ -733,69 +737,6 @@ zoran_i2c_setscl (void *data,
btwrite(zr->i2cbr, ZR36057_I2CBR);
}
-static int
-zoran_i2c_client_register (struct i2c_client *client)
-{
- struct zoran *zr = (struct zoran *) i2c_get_adapdata(client->adapter);
- int res = 0;
-
- dprintk(2,
- KERN_DEBUG "%s: i2c_client_register() - driver id = %d\n",
- ZR_DEVNAME(zr), client->driver->id);
-
- mutex_lock(&zr->resource_lock);
-
- if (zr->user > 0) {
- /* we're already busy, so we keep a reference to
- * them... Could do a lot of stuff here, but this
- * is easiest. (Did I ever mention I'm a lazy ass?)
- */
- res = -EBUSY;
- goto clientreg_unlock_and_return;
- }
-
- if (client->driver->id == zr->card.i2c_decoder)
- zr->decoder = client;
- else if (client->driver->id == zr->card.i2c_encoder)
- zr->encoder = client;
- else {
- res = -ENODEV;
- goto clientreg_unlock_and_return;
- }
-
-clientreg_unlock_and_return:
- mutex_unlock(&zr->resource_lock);
-
- return res;
-}
-
-static int
-zoran_i2c_client_unregister (struct i2c_client *client)
-{
- struct zoran *zr = (struct zoran *) i2c_get_adapdata(client->adapter);
- int res = 0;
-
- dprintk(2, KERN_DEBUG "%s: i2c_client_unregister()\n", ZR_DEVNAME(zr));
-
- mutex_lock(&zr->resource_lock);
-
- if (zr->user > 0) {
- res = -EBUSY;
- goto clientunreg_unlock_and_return;
- }
-
- /* try to locate it */
- if (client == zr->encoder) {
- zr->encoder = NULL;
- } else if (client == zr->decoder) {
- zr->decoder = NULL;
- snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "MJPEG[%d]",
zr->id);
- }
-clientunreg_unlock_and_return:
- mutex_unlock(&zr->resource_lock);
- return res;
-}
-
static const struct i2c_algo_bit_data zoran_i2c_bit_data_template = {
.setsda = zoran_i2c_setsda,
.setscl = zoran_i2c_setscl,
@@ -811,13 +752,10 @@ zoran_register_i2c (struct zoran *zr)
memcpy(&zr->i2c_algo, &zoran_i2c_bit_data_template,
sizeof(struct i2c_algo_bit_data));
zr->i2c_algo.data = zr;
- zr->i2c_adapter.class = I2C_CLASS_TV_ANALOG;
zr->i2c_adapter.id = I2C_HW_B_ZR36067;
- zr->i2c_adapter.client_register = zoran_i2c_client_register;
- zr->i2c_adapter.client_unregister = zoran_i2c_client_unregister;
strlcpy(zr->i2c_adapter.name, ZR_DEVNAME(zr),
sizeof(zr->i2c_adapter.name));
- i2c_set_adapdata(&zr->i2c_adapter, zr);
+ i2c_set_adapdata(&zr->i2c_adapter, &zr->v4l2_dev);
zr->i2c_adapter.algo_data = &zr->i2c_algo;
zr->i2c_adapter.dev.parent = &zr->pci_dev->dev;
return i2c_bit_add_bus(&zr->i2c_adapter);
@@ -1174,8 +1112,8 @@ zr36057_init (struct zoran *zr)
if (!pass_through) {
struct v4l2_routing route = { 2, 0 };
- decoder_command(zr, VIDIOC_STREAMOFF, 0);
- encoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route);
+ decoder_call(zr, video, s_stream, 0);
+ encoder_call(zr, video, s_routing, &route);
}
zr->zoran_proc = NULL;
@@ -1190,7 +1128,8 @@ exit_free:
static void __devexit zoran_remove(struct pci_dev *pdev)
{
- struct zoran *zr = pci_get_drvdata(pdev);
+ struct v4l2_device *v4l2_dev = dev_get_drvdata(&pdev->dev);
+ struct zoran *zr = to_zoran(v4l2_dev);
if (!zr->initialized)
goto exit_free;
@@ -1223,7 +1162,7 @@ static void __devexit zoran_remove(struc
pci_disable_device(zr->pci_dev);
video_unregister_device(zr->video_dev);
exit_free:
- pci_set_drvdata(pdev, NULL);
+ v4l2_device_unregister(&zr->v4l2_dev);
kfree(zr);
}
@@ -1295,7 +1234,7 @@ static int __devinit zoran_probe(struct
struct videocodec_master *master_vfe = NULL;
struct videocodec_master *master_codec = NULL;
int card_num;
- char *i2c_enc_name, *i2c_dec_name, *codec_name, *vfe_name;
+ char *codec_name, *vfe_name;
unsigned int nr;
@@ -1316,13 +1255,15 @@ static int __devinit zoran_probe(struct
ZORAN_NAME);
return -ENOMEM;
}
+ if (v4l2_device_register(&pdev->dev, &zr->v4l2_dev))
+ goto zr_free_mem;
zr->pci_dev = pdev;
zr->id = nr;
snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "MJPEG[%u]", zr->id);
spin_lock_init(&zr->spinlock);
mutex_init(&zr->resource_lock);
if (pci_enable_device(pdev))
- goto zr_free_mem;
+ goto zr_unreg;
pci_read_config_byte(zr->pci_dev, PCI_CLASS_REVISION, &zr->revision);
dprintk(1,
@@ -1349,7 +1290,7 @@ static int __devinit zoran_probe(struct
KERN_ERR
"%s: It is not possible to auto-detect ZR36057
based cards\n",
ZR_DEVNAME(zr));
- goto zr_free_mem;
+ goto zr_unreg;
}
card_num = ent->driver_data;
@@ -1358,7 +1299,7 @@ static int __devinit zoran_probe(struct
KERN_ERR
"%s: Unknown card, try specifying card=X module
parameter\n",
ZR_DEVNAME(zr));
- goto zr_free_mem;
+ goto zr_unreg;
}
dprintk(3,
KERN_DEBUG
@@ -1371,7 +1312,7 @@ static int __devinit zoran_probe(struct
KERN_ERR
"%s: User specified card type %d out of range
(0 .. %d)\n",
ZR_DEVNAME(zr), card_num, NUM_CARDS - 1);
- goto zr_free_mem;
+ goto zr_unreg;
}
}
@@ -1390,7 +1331,7 @@ static int __devinit zoran_probe(struct
KERN_ERR
"%s: %s() - ioremap failed\n",
ZR_DEVNAME(zr), __func__);
- goto zr_free_mem;
+ goto zr_unreg;
}
result = request_irq(zr->pci_dev->irq, zoran_irq,
@@ -1433,46 +1374,6 @@ static int __devinit zoran_probe(struct
dprintk(2, KERN_INFO "%s: Initializing i2c bus...\n",
ZR_DEVNAME(zr));
- /* i2c decoder */
- if (decoder[zr->id] != -1) {
- i2c_dec_name = i2cid_to_modulename(decoder[zr->id]);
- zr->card.i2c_decoder = decoder[zr->id];
- } else if (zr->card.i2c_decoder != 0) {
- i2c_dec_name = i2cid_to_modulename(zr->card.i2c_decoder);
- } else {
- i2c_dec_name = NULL;
- }
-
- if (i2c_dec_name) {
- result = request_module(i2c_dec_name);
- if (result < 0) {
- dprintk(1,
- KERN_ERR
- "%s: failed to load module %s: %d\n",
- ZR_DEVNAME(zr), i2c_dec_name, result);
- }
- }
-
- /* i2c encoder */
- if (encoder[zr->id] != -1) {
- i2c_enc_name = i2cid_to_modulename(encoder[zr->id]);
- zr->card.i2c_encoder = encoder[zr->id];
- } else if (zr->card.i2c_encoder != 0) {
- i2c_enc_name = i2cid_to_modulename(zr->card.i2c_encoder);
- } else {
- i2c_enc_name = NULL;
- }
-
- if (i2c_enc_name) {
- result = request_module(i2c_enc_name);
- if (result < 0) {
- dprintk(1,
- KERN_ERR
- "%s: failed to load module %s: %d\n",
- ZR_DEVNAME(zr), i2c_enc_name, result);
- }
- }
-
if (zoran_register_i2c(zr) < 0) {
dprintk(1,
KERN_ERR
@@ -1480,6 +1381,14 @@ static int __devinit zoran_probe(struct
ZR_DEVNAME(zr));
goto zr_free_irq;
}
+
+ zr->decoder = v4l2_i2c_new_probed_subdev(&zr->i2c_adapter,
+ zr->card.mod_decoder, zr->card.i2c_decoder,
zr->card.addrs_decoder);
+
+ if (zr->card.mod_encoder)
+ zr->encoder = v4l2_i2c_new_probed_subdev(&zr->i2c_adapter,
+ zr->card.mod_encoder, zr->card.i2c_encoder,
+ zr->card.addrs_encoder);
dprintk(2,
KERN_INFO "%s: Initializing videocodec bus...\n",
@@ -1570,8 +1479,6 @@ static int __devinit zoran_probe(struct
zoran_proc_init(zr);
- pci_set_drvdata(pdev, zr);
-
return 0;
zr_detach_vfe:
@@ -1589,6 +1496,8 @@ zr_free_irq:
free_irq(zr->pci_dev->irq, zr);
zr_unmap:
iounmap(zr->zr36057_mem);
+zr_unreg:
+ v4l2_device_unregister(&zr->v4l2_dev);
zr_free_mem:
kfree(zr);
diff -r 7ab48645e84b -r a5c93b7614e4
linux/drivers/media/video/zoran/zoran_device.c
--- a/linux/drivers/media/video/zoran/zoran_device.c Thu Feb 19 18:56:37
2009 +0100
+++ b/linux/drivers/media/video/zoran/zoran_device.c Thu Feb 19 20:18:23
2009 +0100
@@ -37,15 +37,12 @@
#include <linux/i2c.h>
#include <linux/i2c-algo-bit.h>
#include "compat.h"
-#include <linux/videodev.h>
#include <linux/videodev2.h>
#include <media/v4l2-common.h>
#include <linux/spinlock.h>
#include <linux/sem.h>
#include <linux/pci.h>
-#include <linux/video_decoder.h>
-#include <linux/video_encoder.h>
#include <linux/delay.h>
#include <linux/wait.h>
@@ -1001,9 +998,9 @@ zr36057_enable_jpg (struct zoran
* the video bus direction set to input.
*/
set_videobus_dir(zr, 0);
- decoder_command(zr, VIDIOC_STREAMON, 0);
+ decoder_call(zr, video, s_stream, 1);
route.input = 0;
- encoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route);
+ encoder_call(zr, video, s_routing, &route);
/* Take the JPEG codec and the VFE out of sleep */
jpeg_codec_sleep(zr, 0);
@@ -1049,10 +1046,10 @@ zr36057_enable_jpg (struct zoran
/* In motion decompression mode, the decoder output must be
disabled, and
* the video bus direction set to output.
*/
- decoder_command(zr, VIDIOC_STREAMOFF, 0);
+ decoder_call(zr, video, s_stream, 0);
set_videobus_dir(zr, 1);
route.input = 1;
- encoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route);
+ encoder_call(zr, video, s_routing, &route);
/* Take the JPEG codec and the VFE out of sleep */
jpeg_codec_sleep(zr, 0);
@@ -1096,9 +1093,9 @@ zr36057_enable_jpg (struct zoran
jpeg_codec_sleep(zr, 1);
zr36057_adjust_vfe(zr, mode);
- decoder_command(zr, VIDIOC_STREAMON, 0);
+ decoder_call(zr, video, s_stream, 1);
route.input = 0;
- encoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route);
+ encoder_call(zr, video, s_routing, &route);
dprintk(2, KERN_INFO "%s: enable_jpg(IDLE)\n", ZR_DEVNAME(zr));
break;
@@ -1211,7 +1208,7 @@ static void zoran_restart(struct zoran *
int status = 0, mode;
if (zr->codec_mode == BUZ_MODE_MOTION_COMPRESS) {
- decoder_command(zr, VIDIOC_INT_G_INPUT_STATUS, &status);
+ decoder_call(zr, video, g_input_status, &status);
mode = CODEC_DO_COMPRESSION;
} else {
status = V4L2_IN_ST_NO_SIGNAL;
@@ -1596,14 +1593,14 @@ zoran_init_hardware (struct zoran *zr)
route.input = zr->card.input[zr->input].muxsel;
- decoder_command(zr, VIDIOC_INT_INIT, NULL);
- decoder_command(zr, VIDIOC_S_STD, &zr->norm);
- decoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route);
-
- encoder_command(zr, VIDIOC_INT_INIT, NULL);
- encoder_command(zr, VIDIOC_INT_S_STD_OUTPUT, &zr->norm);
+ decoder_call(zr, core, init, 0);
+ decoder_s_std(zr, zr->norm);
+ decoder_s_routing(zr, &route);
+
+ encoder_call(zr, core, init, 0);
+ encoder_call(zr, video, s_std_output, zr->norm);
route.input = 0;
- encoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route);
+ encoder_call(zr, video, s_routing, &route);
/* toggle JPEG codec sleep to sync PLL */
jpeg_codec_sleep(zr, 1);
@@ -1668,37 +1665,30 @@ zr36057_init_vfe (struct zoran *zr)
* Interface to decoder and encoder chips using i2c bus
*/
-int
-decoder_command (struct zoran *zr,
- int cmd,
- void *data)
-{
- if (zr->decoder == NULL)
- return -EIO;
-
- if (zr->card.type == LML33 &&
- (cmd == VIDIOC_S_STD || cmd == VIDIOC_INT_S_VIDEO_ROUTING)) {
- int res;
-
- // Bt819 needs to reset its FIFO buffer using #FRST pin and
- // LML33 card uses GPIO(7) for that.
+int decoder_s_std(struct zoran *zr, v4l2_std_id std)
+{
+ int res;
+
+ /* Bt819 needs to reset its FIFO buffer using #FRST pin and
+ LML33 card uses GPIO(7) for that. */
+ if (zr->card.type == LML33)
GPIO(zr, 7, 0);
- res = zr->decoder->driver->command(zr->decoder, cmd, data);
- // Pull #FRST high.
- GPIO(zr, 7, 1);
- return res;
- } else
- return zr->decoder->driver->command(zr->decoder, cmd,
- data);
-}
-
-int
-encoder_command (struct zoran *zr,
- int cmd,
- void *data)
-{
- if (zr->encoder == NULL)
- return -1;
-
- return zr->encoder->driver->command(zr->encoder, cmd, data);
-}
+ res = decoder_call(zr, tuner, s_std, std);
+ if (zr->card.type == LML33)
+ GPIO(zr, 7, 1); /* Pull #FRST high. */
+ return res;
+}
+
+int decoder_s_routing(struct zoran *zr, struct v4l2_routing *route)
+{
+ int res;
+
+ /* Bt819 needs to reset its FIFO buffer using #FRST pin and
+ LML33 card uses GPIO(7) for that. */
+ if (zr->card.type == LML33)
+ GPIO(zr, 7, 0);
+ res = decoder_call(zr, video, s_routing, route);
+ if (zr->card.type == LML33)
+ GPIO(zr, 7, 1); /* Pull #FRST high. */
+ return res;
+}
diff -r 7ab48645e84b -r a5c93b7614e4
linux/drivers/media/video/zoran/zoran_device.h
--- a/linux/drivers/media/video/zoran/zoran_device.h Thu Feb 19 18:56:37
2009 +0100
+++ b/linux/drivers/media/video/zoran/zoran_device.h Thu Feb 19 20:18:23
2009 +0100
@@ -93,11 +93,12 @@ extern int pass_through;
extern int pass_through;
/* i2c */
-extern int decoder_command(struct zoran *zr,
- int cmd,
- void *data);
-extern int encoder_command(struct zoran *zr,
- int cmd,
- void *data);
+#define decoder_call(zr, o, f, args...) \
+ v4l2_subdev_call(zr->decoder, o, f, ##args)
+#define encoder_call(zr, o, f, args...) \
+ v4l2_subdev_call(zr->encoder, o, f, ##args)
+
+int decoder_s_std(struct zoran *zr, v4l2_std_id std);
+int decoder_s_routing(struct zoran *zr, struct v4l2_routing *route);
#endif /* __ZORAN_DEVICE_H__ */
diff -r 7ab48645e84b -r a5c93b7614e4
linux/drivers/media/video/zoran/zoran_driver.c
--- a/linux/drivers/media/video/zoran/zoran_driver.c Thu Feb 19 18:56:37
2009 +0100
+++ b/linux/drivers/media/video/zoran/zoran_driver.c Thu Feb 19 20:18:23
2009 +0100
@@ -964,41 +964,11 @@ static int zoran_open(struct file *file)
lock_kernel();
- /* see fs/device.c - the kernel already locks during open(),
- * so locking ourselves only causes deadlocks */
- /*mutex_lock(&zr->resource_lock);*/
-
if (zr->user >= 2048) {
dprintk(1, KERN_ERR "%s: too many users (%d) on device\n",
ZR_DEVNAME(zr), zr->user);
res = -EBUSY;
goto fail_unlock;
- }
-
- if (!zr->decoder) {
- dprintk(1,
- KERN_ERR "%s: no TV decoder loaded for device!\n",
- ZR_DEVNAME(zr));
- res = -EIO;
- goto fail_unlock;
- }
-
- if (!try_module_get(zr->decoder->driver->driver.owner)) {
- dprintk(1,
- KERN_ERR
- "%s: failed to grab ownership of video decoder\n",
- ZR_DEVNAME(zr));
- res = -EIO;
- goto fail_unlock;
- }
- if (zr->encoder &&
- !try_module_get(zr->encoder->driver->driver.owner)) {
- dprintk(1,
- KERN_ERR
- "%s: failed to grab ownership of video encoder\n",
- ZR_DEVNAME(zr));
- res = -EIO;
- goto fail_decoder;
}
/* now, create the open()-specific file_ops struct */
@@ -1009,7 +979,7 @@ static int zoran_open(struct file *file)
"%s: zoran_open() - allocation of zoran_fh failed\n",
ZR_DEVNAME(zr));
res = -ENOMEM;
- goto fail_encoder;
+ goto fail_unlock;
}
/* used to be BUZ_MAX_WIDTH/HEIGHT, but that gives overflows
* on norm-change! */
@@ -1048,11 +1018,6 @@ static int zoran_open(struct file *file)
fail_fh:
kfree(fh);
-fail_encoder:
- if (zr->encoder)
- module_put(zr->encoder->driver->driver.owner);
-fail_decoder:
- module_put(zr->decoder->driver->driver.owner);
fail_unlock:
unlock_kernel();
@@ -1105,21 +1070,14 @@ zoran_close(struct file *file)
if (!pass_through) { /* Switch to color bar */
struct v4l2_routing route = { 2, 0 };
- decoder_command(zr, VIDIOC_STREAMOFF, 0);
- encoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route);
+ decoder_call(zr, video, s_stream, 0);
+ encoder_call(zr, video, s_routing, &route);
}
}
file->private_data = NULL;
kfree(fh->overlay_mask);
kfree(fh);
-
- /* release locks on the i2c modules */
- module_put(zr->decoder->driver->driver.owner);
- if (zr->encoder)
- module_put(zr->encoder->driver->driver.owner);
-
- /*mutex_unlock(&zr->resource_lock);*/
dprintk(4, KERN_INFO "%s: zoran_close() done\n", ZR_DEVNAME(zr));
@@ -1568,20 +1526,20 @@ zoran_set_norm (struct zoran *zr,
int status = 0;
v4l2_std_id std = 0;
- decoder_command(zr, VIDIOC_QUERYSTD, &std);
- decoder_command(zr, VIDIOC_S_STD, &std);
+ decoder_call(zr, video, querystd, &std);
+ decoder_s_std(zr, std);
/* let changes come into effect */
ssleep(2);
- decoder_command(zr, VIDIOC_INT_G_INPUT_STATUS, &status);
+ decoder_call(zr, video, g_input_status, &status);
if (status & V4L2_IN_ST_NO_SIGNAL) {
dprintk(1,
KERN_ERR
"%s: set_norm() - no norm detected\n",
ZR_DEVNAME(zr));
/* reset norm */
- decoder_command(zr, VIDIOC_S_STD, &zr->norm);
+ decoder_s_std(zr, zr->norm);
return -EIO;
}
@@ -1600,8 +1558,8 @@ zoran_set_norm (struct zoran *zr,
if (on)
zr36057_overlay(zr, 0);
- decoder_command(zr, VIDIOC_S_STD, &norm);
- encoder_command(zr, VIDIOC_INT_S_STD_OUTPUT, &norm);
+ decoder_s_std(zr, norm);
+ encoder_call(zr, video, s_std_output, norm);
if (on)
zr36057_overlay(zr, 1);
@@ -1642,7 +1600,7 @@ zoran_set_input (struct zoran *zr,
route.input = zr->card.input[input].muxsel;
zr->input = input;
- decoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route);
+ decoder_s_routing(zr, &route);
return 0;
}
@@ -1887,18 +1845,18 @@ jpgreqbuf_unlock_and_return:
goto gstat_unlock_and_return;
}
- decoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route);
+ decoder_s_routing(zr, &route);
/* sleep 1 second */
ssleep(1);
/* Get status of video decoder */
- decoder_command(zr, VIDIOC_QUERYSTD, &norm);
- decoder_command(zr, VIDIOC_INT_G_INPUT_STATUS, &status);
+ decoder_call(zr, video, querystd, &norm);
+ decoder_call(zr, video, g_input_status, &status);
/* restore previous input and norm */
route.input = zr->card.input[zr->input].muxsel;
- decoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route);
+ decoder_s_routing(zr, &route);
gstat_unlock_and_return:
mutex_unlock(&zr->resource_lock);
@@ -2837,7 +2795,7 @@ static int zoran_queryctrl(struct file *
ctrl->id > V4L2_CID_HUE)
return -EINVAL;
- decoder_command(zr, VIDIOC_QUERYCTRL, ctrl);
+ decoder_call(zr, core, queryctrl, ctrl);
return 0;
}
@@ -2853,7 +2811,7 @@ static int zoran_g_ctrl(struct file *fil
return -EINVAL;
mutex_lock(&zr->resource_lock);
- decoder_command(zr, VIDIOC_G_CTRL, ctrl);
+ decoder_call(zr, core, g_ctrl, ctrl);
mutex_unlock(&zr->resource_lock);
return 0;
@@ -2870,7 +2828,7 @@ static int zoran_s_ctrl(struct file *fil
return -EINVAL;
mutex_lock(&zr->resource_lock);
- decoder_command(zr, VIDIOC_S_CTRL, ctrl);
+ decoder_call(zr, core, s_ctrl, ctrl);
mutex_unlock(&zr->resource_lock);
return 0;
@@ -2925,7 +2883,7 @@ static int zoran_enum_input(struct file
/* Get status of video decoder */
mutex_lock(&zr->resource_lock);
- decoder_command(zr, VIDIOC_INT_G_INPUT_STATUS, &inp->status);
+ decoder_call(zr, video, g_input_status, &inp->status);
mutex_unlock(&zr->resource_lock);
return 0;
}
---
Patch is available at:
http://linuxtv.org/hg/v4l-dvb/rev/a5c93b7614e4637de89c696f6ff739dc9a300c58
_______________________________________________
linuxtv-commits mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits