V4L/DVB (7406): soc-camera: improve separation between soc_camera_ops and soc_camera_device
In case of muliple cameras, handled by the same driver, they can support Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
This commit is contained in:
committed by
Mauro Carvalho Chehab
parent
8be38c815e
commit
26f1b94215
@@ -410,11 +410,15 @@ const struct v4l2_queryctrl mt9m001_controls[] = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static int mt9m001_get_control(struct soc_camera_device *icd, struct v4l2_control *ctrl);
|
static int mt9m001_video_probe(struct soc_camera_device *);
|
||||||
static int mt9m001_set_control(struct soc_camera_device *icd, struct v4l2_control *ctrl);
|
static void mt9m001_video_remove(struct soc_camera_device *);
|
||||||
|
static int mt9m001_get_control(struct soc_camera_device *, struct v4l2_control *);
|
||||||
|
static int mt9m001_set_control(struct soc_camera_device *, struct v4l2_control *);
|
||||||
|
|
||||||
static struct soc_camera_ops mt9m001_ops = {
|
static struct soc_camera_ops mt9m001_ops = {
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
|
.probe = mt9m001_video_probe,
|
||||||
|
.remove = mt9m001_video_remove,
|
||||||
.init = mt9m001_init,
|
.init = mt9m001_init,
|
||||||
.release = mt9m001_release,
|
.release = mt9m001_release,
|
||||||
.start_capture = mt9m001_start_capture,
|
.start_capture = mt9m001_start_capture,
|
||||||
@@ -423,8 +427,6 @@ static struct soc_camera_ops mt9m001_ops = {
|
|||||||
.try_fmt_cap = mt9m001_try_fmt_cap,
|
.try_fmt_cap = mt9m001_try_fmt_cap,
|
||||||
.set_bus_param = mt9m001_set_bus_param,
|
.set_bus_param = mt9m001_set_bus_param,
|
||||||
.query_bus_param = mt9m001_query_bus_param,
|
.query_bus_param = mt9m001_query_bus_param,
|
||||||
.formats = NULL, /* Filled in later depending on the */
|
|
||||||
.num_formats = 0, /* camera type and data widths */
|
|
||||||
.controls = mt9m001_controls,
|
.controls = mt9m001_controls,
|
||||||
.num_controls = ARRAY_SIZE(mt9m001_controls),
|
.num_controls = ARRAY_SIZE(mt9m001_controls),
|
||||||
.get_control = mt9m001_get_control,
|
.get_control = mt9m001_get_control,
|
||||||
@@ -573,19 +575,19 @@ static int mt9m001_video_probe(struct soc_camera_device *icd)
|
|||||||
case 0x8411:
|
case 0x8411:
|
||||||
case 0x8421:
|
case 0x8421:
|
||||||
mt9m001->model = V4L2_IDENT_MT9M001C12ST;
|
mt9m001->model = V4L2_IDENT_MT9M001C12ST;
|
||||||
mt9m001_ops.formats = mt9m001_colour_formats;
|
icd->formats = mt9m001_colour_formats;
|
||||||
if (mt9m001->client->dev.platform_data)
|
if (mt9m001->client->dev.platform_data)
|
||||||
mt9m001_ops.num_formats = ARRAY_SIZE(mt9m001_colour_formats);
|
icd->num_formats = ARRAY_SIZE(mt9m001_colour_formats);
|
||||||
else
|
else
|
||||||
mt9m001_ops.num_formats = 1;
|
icd->num_formats = 1;
|
||||||
break;
|
break;
|
||||||
case 0x8431:
|
case 0x8431:
|
||||||
mt9m001->model = V4L2_IDENT_MT9M001C12STM;
|
mt9m001->model = V4L2_IDENT_MT9M001C12STM;
|
||||||
mt9m001_ops.formats = mt9m001_monochrome_formats;
|
icd->formats = mt9m001_monochrome_formats;
|
||||||
if (mt9m001->client->dev.platform_data)
|
if (mt9m001->client->dev.platform_data)
|
||||||
mt9m001_ops.num_formats = ARRAY_SIZE(mt9m001_monochrome_formats);
|
icd->num_formats = ARRAY_SIZE(mt9m001_monochrome_formats);
|
||||||
else
|
else
|
||||||
mt9m001_ops.num_formats = 1;
|
icd->num_formats = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = -ENODEV;
|
ret = -ENODEV;
|
||||||
@@ -646,8 +648,6 @@ static int mt9m001_probe(struct i2c_client *client)
|
|||||||
|
|
||||||
/* Second stage probe - when a capture adapter is there */
|
/* Second stage probe - when a capture adapter is there */
|
||||||
icd = &mt9m001->icd;
|
icd = &mt9m001->icd;
|
||||||
icd->probe = mt9m001_video_probe;
|
|
||||||
icd->remove = mt9m001_video_remove;
|
|
||||||
icd->ops = &mt9m001_ops;
|
icd->ops = &mt9m001_ops;
|
||||||
icd->control = &client->dev;
|
icd->control = &client->dev;
|
||||||
icd->x_min = 20;
|
icd->x_min = 20;
|
||||||
|
@@ -506,13 +506,15 @@ const struct v4l2_queryctrl mt9v022_controls[] = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static int mt9v022_get_control(struct soc_camera_device *icd,
|
static int mt9v022_video_probe(struct soc_camera_device *);
|
||||||
struct v4l2_control *ctrl);
|
static void mt9v022_video_remove(struct soc_camera_device *);
|
||||||
static int mt9v022_set_control(struct soc_camera_device *icd,
|
static int mt9v022_get_control(struct soc_camera_device *, struct v4l2_control *);
|
||||||
struct v4l2_control *ctrl);
|
static int mt9v022_set_control(struct soc_camera_device *, struct v4l2_control *);
|
||||||
|
|
||||||
static struct soc_camera_ops mt9v022_ops = {
|
static struct soc_camera_ops mt9v022_ops = {
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
|
.probe = mt9v022_video_probe,
|
||||||
|
.remove = mt9v022_video_remove,
|
||||||
.init = mt9v022_init,
|
.init = mt9v022_init,
|
||||||
.release = mt9v022_release,
|
.release = mt9v022_release,
|
||||||
.start_capture = mt9v022_start_capture,
|
.start_capture = mt9v022_start_capture,
|
||||||
@@ -521,8 +523,6 @@ static struct soc_camera_ops mt9v022_ops = {
|
|||||||
.try_fmt_cap = mt9v022_try_fmt_cap,
|
.try_fmt_cap = mt9v022_try_fmt_cap,
|
||||||
.set_bus_param = mt9v022_set_bus_param,
|
.set_bus_param = mt9v022_set_bus_param,
|
||||||
.query_bus_param = mt9v022_query_bus_param,
|
.query_bus_param = mt9v022_query_bus_param,
|
||||||
.formats = NULL, /* Filled in later depending on the */
|
|
||||||
.num_formats = 0, /* sensor type and data widths */
|
|
||||||
.controls = mt9v022_controls,
|
.controls = mt9v022_controls,
|
||||||
.num_controls = ARRAY_SIZE(mt9v022_controls),
|
.num_controls = ARRAY_SIZE(mt9v022_controls),
|
||||||
.get_control = mt9v022_get_control,
|
.get_control = mt9v022_get_control,
|
||||||
@@ -705,19 +705,19 @@ static int mt9v022_video_probe(struct soc_camera_device *icd)
|
|||||||
!strcmp("color", sensor_type))) {
|
!strcmp("color", sensor_type))) {
|
||||||
ret = reg_write(icd, MT9V022_PIXEL_OPERATION_MODE, 4 | 0x11);
|
ret = reg_write(icd, MT9V022_PIXEL_OPERATION_MODE, 4 | 0x11);
|
||||||
mt9v022->model = V4L2_IDENT_MT9V022IX7ATC;
|
mt9v022->model = V4L2_IDENT_MT9V022IX7ATC;
|
||||||
mt9v022_ops.formats = mt9v022_colour_formats;
|
icd->formats = mt9v022_colour_formats;
|
||||||
if (mt9v022->client->dev.platform_data)
|
if (mt9v022->client->dev.platform_data)
|
||||||
mt9v022_ops.num_formats = ARRAY_SIZE(mt9v022_colour_formats);
|
icd->num_formats = ARRAY_SIZE(mt9v022_colour_formats);
|
||||||
else
|
else
|
||||||
mt9v022_ops.num_formats = 1;
|
icd->num_formats = 1;
|
||||||
} else {
|
} else {
|
||||||
ret = reg_write(icd, MT9V022_PIXEL_OPERATION_MODE, 0x11);
|
ret = reg_write(icd, MT9V022_PIXEL_OPERATION_MODE, 0x11);
|
||||||
mt9v022->model = V4L2_IDENT_MT9V022IX7ATM;
|
mt9v022->model = V4L2_IDENT_MT9V022IX7ATM;
|
||||||
mt9v022_ops.formats = mt9v022_monochrome_formats;
|
icd->formats = mt9v022_monochrome_formats;
|
||||||
if (mt9v022->client->dev.platform_data)
|
if (mt9v022->client->dev.platform_data)
|
||||||
mt9v022_ops.num_formats = ARRAY_SIZE(mt9v022_monochrome_formats);
|
icd->num_formats = ARRAY_SIZE(mt9v022_monochrome_formats);
|
||||||
else
|
else
|
||||||
mt9v022_ops.num_formats = 1;
|
icd->num_formats = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
@@ -773,8 +773,6 @@ static int mt9v022_probe(struct i2c_client *client)
|
|||||||
i2c_set_clientdata(client, mt9v022);
|
i2c_set_clientdata(client, mt9v022);
|
||||||
|
|
||||||
icd = &mt9v022->icd;
|
icd = &mt9v022->icd;
|
||||||
icd->probe = mt9v022_video_probe;
|
|
||||||
icd->remove = mt9v022_video_remove;
|
|
||||||
icd->ops = &mt9v022_ops;
|
icd->ops = &mt9v022_ops;
|
||||||
icd->control = &client->dev;
|
icd->control = &client->dev;
|
||||||
icd->x_min = 1;
|
icd->x_min = 1;
|
||||||
|
@@ -38,9 +38,9 @@ format_by_fourcc(struct soc_camera_device *icd, unsigned int fourcc)
|
|||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
for (i = 0; i < icd->ops->num_formats; i++)
|
for (i = 0; i < icd->num_formats; i++)
|
||||||
if (icd->ops->formats[i].fourcc == fourcc)
|
if (icd->formats[i].fourcc == fourcc)
|
||||||
return icd->ops->formats + i;
|
return icd->formats + i;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -384,10 +384,10 @@ static int soc_camera_enum_fmt_cap(struct file *file, void *priv,
|
|||||||
|
|
||||||
WARN_ON(priv != file->private_data);
|
WARN_ON(priv != file->private_data);
|
||||||
|
|
||||||
if (f->index >= icd->ops->num_formats)
|
if (f->index >= icd->num_formats)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
format = &icd->ops->formats[f->index];
|
format = &icd->formats[f->index];
|
||||||
|
|
||||||
strlcpy(f->description, format->name, sizeof(f->description));
|
strlcpy(f->description, format->name, sizeof(f->description));
|
||||||
f->pixelformat = format->fourcc;
|
f->pixelformat = format->fourcc;
|
||||||
@@ -701,7 +701,7 @@ static int soc_camera_probe(struct device *dev)
|
|||||||
to_soc_camera_host(icd->dev.parent);
|
to_soc_camera_host(icd->dev.parent);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!icd->probe)
|
if (!icd->ops->probe)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
/* We only call ->add() here to activate and probe the camera.
|
/* We only call ->add() here to activate and probe the camera.
|
||||||
@@ -710,7 +710,7 @@ static int soc_camera_probe(struct device *dev)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = icd->probe(icd);
|
ret = icd->ops->probe(icd);
|
||||||
if (ret >= 0) {
|
if (ret >= 0) {
|
||||||
const struct v4l2_queryctrl *qctrl;
|
const struct v4l2_queryctrl *qctrl;
|
||||||
|
|
||||||
@@ -731,8 +731,8 @@ static int soc_camera_remove(struct device *dev)
|
|||||||
{
|
{
|
||||||
struct soc_camera_device *icd = to_soc_camera_dev(dev);
|
struct soc_camera_device *icd = to_soc_camera_dev(dev);
|
||||||
|
|
||||||
if (icd->remove)
|
if (icd->ops->remove)
|
||||||
icd->remove(icd);
|
icd->ops->remove(icd);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -928,7 +928,7 @@ int soc_camera_video_start(struct soc_camera_device *icd)
|
|||||||
vdev->vidioc_s_register = soc_camera_s_register;
|
vdev->vidioc_s_register = soc_camera_s_register;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
icd->current_fmt = &icd->ops->formats[0];
|
icd->current_fmt = &icd->formats[0];
|
||||||
|
|
||||||
err = video_register_device(vdev, VFL_TYPE_GRABBER, vdev->minor);
|
err = video_register_device(vdev, VFL_TYPE_GRABBER, vdev->minor);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
|
@@ -38,8 +38,8 @@ struct soc_camera_device {
|
|||||||
struct soc_camera_ops *ops;
|
struct soc_camera_ops *ops;
|
||||||
struct video_device *vdev;
|
struct video_device *vdev;
|
||||||
const struct soc_camera_data_format *current_fmt;
|
const struct soc_camera_data_format *current_fmt;
|
||||||
int (*probe)(struct soc_camera_device *icd);
|
const struct soc_camera_data_format *formats;
|
||||||
void (*remove)(struct soc_camera_device *icd);
|
int num_formats;
|
||||||
struct module *owner;
|
struct module *owner;
|
||||||
/* soc_camera.c private count. Only accessed with video_lock held */
|
/* soc_camera.c private count. Only accessed with video_lock held */
|
||||||
int use_count;
|
int use_count;
|
||||||
@@ -106,6 +106,8 @@ struct soc_camera_data_format {
|
|||||||
|
|
||||||
struct soc_camera_ops {
|
struct soc_camera_ops {
|
||||||
struct module *owner;
|
struct module *owner;
|
||||||
|
int (*probe)(struct soc_camera_device *);
|
||||||
|
void (*remove)(struct soc_camera_device *);
|
||||||
int (*init)(struct soc_camera_device *);
|
int (*init)(struct soc_camera_device *);
|
||||||
int (*release)(struct soc_camera_device *);
|
int (*release)(struct soc_camera_device *);
|
||||||
int (*start_capture)(struct soc_camera_device *);
|
int (*start_capture)(struct soc_camera_device *);
|
||||||
@@ -121,8 +123,6 @@ struct soc_camera_ops {
|
|||||||
int (*get_register)(struct soc_camera_device *, struct v4l2_register *);
|
int (*get_register)(struct soc_camera_device *, struct v4l2_register *);
|
||||||
int (*set_register)(struct soc_camera_device *, struct v4l2_register *);
|
int (*set_register)(struct soc_camera_device *, struct v4l2_register *);
|
||||||
#endif
|
#endif
|
||||||
const struct soc_camera_data_format *formats;
|
|
||||||
int num_formats;
|
|
||||||
int (*get_control)(struct soc_camera_device *, struct v4l2_control *);
|
int (*get_control)(struct soc_camera_device *, struct v4l2_control *);
|
||||||
int (*set_control)(struct soc_camera_device *, struct v4l2_control *);
|
int (*set_control)(struct soc_camera_device *, struct v4l2_control *);
|
||||||
const struct v4l2_queryctrl *controls;
|
const struct v4l2_queryctrl *controls;
|
||||||
|
Reference in New Issue
Block a user