aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@pengutronix.de>2008-03-24 11:18:36 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-04-24 13:07:53 -0400
commit26f1b942156766c6ff1a70fb2ac463c6fce31309 (patch)
tree20799de356a6876dabbf1366963f849cb7f2889c
parent8be38c815e181402c777e033f40971a7be19cf8b (diff)
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>
-rw-r--r--drivers/media/video/mt9m001.c24
-rw-r--r--drivers/media/video/mt9v022.c26
-rw-r--r--drivers/media/video/soc_camera.c20
-rw-r--r--include/media/soc_camera.h8
4 files changed, 38 insertions, 40 deletions
diff --git a/drivers/media/video/mt9m001.c b/drivers/media/video/mt9m001.c
index acb5454b57eb..2ea133e8a625 100644
--- a/drivers/media/video/mt9m001.c
+++ b/drivers/media/video/mt9m001.c
@@ -410,11 +410,15 @@ const struct v4l2_queryctrl mt9m001_controls[] = {
410 } 410 }
411}; 411};
412 412
413static int mt9m001_get_control(struct soc_camera_device *icd, struct v4l2_control *ctrl); 413static int mt9m001_video_probe(struct soc_camera_device *);
414static int mt9m001_set_control(struct soc_camera_device *icd, struct v4l2_control *ctrl); 414static void mt9m001_video_remove(struct soc_camera_device *);
415static int mt9m001_get_control(struct soc_camera_device *, struct v4l2_control *);
416static int mt9m001_set_control(struct soc_camera_device *, struct v4l2_control *);
415 417
416static struct soc_camera_ops mt9m001_ops = { 418static struct soc_camera_ops mt9m001_ops = {
417 .owner = THIS_MODULE, 419 .owner = THIS_MODULE,
420 .probe = mt9m001_video_probe,
421 .remove = mt9m001_video_remove,
418 .init = mt9m001_init, 422 .init = mt9m001_init,
419 .release = mt9m001_release, 423 .release = mt9m001_release,
420 .start_capture = mt9m001_start_capture, 424 .start_capture = mt9m001_start_capture,
@@ -423,8 +427,6 @@ static struct soc_camera_ops mt9m001_ops = {
423 .try_fmt_cap = mt9m001_try_fmt_cap, 427 .try_fmt_cap = mt9m001_try_fmt_cap,
424 .set_bus_param = mt9m001_set_bus_param, 428 .set_bus_param = mt9m001_set_bus_param,
425 .query_bus_param = mt9m001_query_bus_param, 429 .query_bus_param = mt9m001_query_bus_param,
426 .formats = NULL, /* Filled in later depending on the */
427 .num_formats = 0, /* camera type and data widths */
428 .controls = mt9m001_controls, 430 .controls = mt9m001_controls,
429 .num_controls = ARRAY_SIZE(mt9m001_controls), 431 .num_controls = ARRAY_SIZE(mt9m001_controls),
430 .get_control = mt9m001_get_control, 432 .get_control = mt9m001_get_control,
@@ -573,19 +575,19 @@ static int mt9m001_video_probe(struct soc_camera_device *icd)
573 case 0x8411: 575 case 0x8411:
574 case 0x8421: 576 case 0x8421:
575 mt9m001->model = V4L2_IDENT_MT9M001C12ST; 577 mt9m001->model = V4L2_IDENT_MT9M001C12ST;
576 mt9m001_ops.formats = mt9m001_colour_formats; 578 icd->formats = mt9m001_colour_formats;
577 if (mt9m001->client->dev.platform_data) 579 if (mt9m001->client->dev.platform_data)
578 mt9m001_ops.num_formats = ARRAY_SIZE(mt9m001_colour_formats); 580 icd->num_formats = ARRAY_SIZE(mt9m001_colour_formats);
579 else 581 else
580 mt9m001_ops.num_formats = 1; 582 icd->num_formats = 1;
581 break; 583 break;
582 case 0x8431: 584 case 0x8431:
583 mt9m001->model = V4L2_IDENT_MT9M001C12STM; 585 mt9m001->model = V4L2_IDENT_MT9M001C12STM;
584 mt9m001_ops.formats = mt9m001_monochrome_formats; 586 icd->formats = mt9m001_monochrome_formats;
585 if (mt9m001->client->dev.platform_data) 587 if (mt9m001->client->dev.platform_data)
586 mt9m001_ops.num_formats = ARRAY_SIZE(mt9m001_monochrome_formats); 588 icd->num_formats = ARRAY_SIZE(mt9m001_monochrome_formats);
587 else 589 else
588 mt9m001_ops.num_formats = 1; 590 icd->num_formats = 1;
589 break; 591 break;
590 default: 592 default:
591 ret = -ENODEV; 593 ret = -ENODEV;
@@ -646,8 +648,6 @@ static int mt9m001_probe(struct i2c_client *client)
646 648
647 /* Second stage probe - when a capture adapter is there */ 649 /* Second stage probe - when a capture adapter is there */
648 icd = &mt9m001->icd; 650 icd = &mt9m001->icd;
649 icd->probe = mt9m001_video_probe;
650 icd->remove = mt9m001_video_remove;
651 icd->ops = &mt9m001_ops; 651 icd->ops = &mt9m001_ops;
652 icd->control = &client->dev; 652 icd->control = &client->dev;
653 icd->x_min = 20; 653 icd->x_min = 20;
diff --git a/drivers/media/video/mt9v022.c b/drivers/media/video/mt9v022.c
index a2f161dcc72d..d4b9e2744343 100644
--- a/drivers/media/video/mt9v022.c
+++ b/drivers/media/video/mt9v022.c
@@ -506,13 +506,15 @@ const struct v4l2_queryctrl mt9v022_controls[] = {
506 } 506 }
507}; 507};
508 508
509static int mt9v022_get_control(struct soc_camera_device *icd, 509static int mt9v022_video_probe(struct soc_camera_device *);
510 struct v4l2_control *ctrl); 510static void mt9v022_video_remove(struct soc_camera_device *);
511static int mt9v022_set_control(struct soc_camera_device *icd, 511static int mt9v022_get_control(struct soc_camera_device *, struct v4l2_control *);
512 struct v4l2_control *ctrl); 512static int mt9v022_set_control(struct soc_camera_device *, struct v4l2_control *);
513 513
514static struct soc_camera_ops mt9v022_ops = { 514static struct soc_camera_ops mt9v022_ops = {
515 .owner = THIS_MODULE, 515 .owner = THIS_MODULE,
516 .probe = mt9v022_video_probe,
517 .remove = mt9v022_video_remove,
516 .init = mt9v022_init, 518 .init = mt9v022_init,
517 .release = mt9v022_release, 519 .release = mt9v022_release,
518 .start_capture = mt9v022_start_capture, 520 .start_capture = mt9v022_start_capture,
@@ -521,8 +523,6 @@ static struct soc_camera_ops mt9v022_ops = {
521 .try_fmt_cap = mt9v022_try_fmt_cap, 523 .try_fmt_cap = mt9v022_try_fmt_cap,
522 .set_bus_param = mt9v022_set_bus_param, 524 .set_bus_param = mt9v022_set_bus_param,
523 .query_bus_param = mt9v022_query_bus_param, 525 .query_bus_param = mt9v022_query_bus_param,
524 .formats = NULL, /* Filled in later depending on the */
525 .num_formats = 0, /* sensor type and data widths */
526 .controls = mt9v022_controls, 526 .controls = mt9v022_controls,
527 .num_controls = ARRAY_SIZE(mt9v022_controls), 527 .num_controls = ARRAY_SIZE(mt9v022_controls),
528 .get_control = mt9v022_get_control, 528 .get_control = mt9v022_get_control,
@@ -705,19 +705,19 @@ static int mt9v022_video_probe(struct soc_camera_device *icd)
705 !strcmp("color", sensor_type))) { 705 !strcmp("color", sensor_type))) {
706 ret = reg_write(icd, MT9V022_PIXEL_OPERATION_MODE, 4 | 0x11); 706 ret = reg_write(icd, MT9V022_PIXEL_OPERATION_MODE, 4 | 0x11);
707 mt9v022->model = V4L2_IDENT_MT9V022IX7ATC; 707 mt9v022->model = V4L2_IDENT_MT9V022IX7ATC;
708 mt9v022_ops.formats = mt9v022_colour_formats; 708 icd->formats = mt9v022_colour_formats;
709 if (mt9v022->client->dev.platform_data) 709 if (mt9v022->client->dev.platform_data)
710 mt9v022_ops.num_formats = ARRAY_SIZE(mt9v022_colour_formats); 710 icd->num_formats = ARRAY_SIZE(mt9v022_colour_formats);
711 else 711 else
712 mt9v022_ops.num_formats = 1; 712 icd->num_formats = 1;
713 } else { 713 } else {
714 ret = reg_write(icd, MT9V022_PIXEL_OPERATION_MODE, 0x11); 714 ret = reg_write(icd, MT9V022_PIXEL_OPERATION_MODE, 0x11);
715 mt9v022->model = V4L2_IDENT_MT9V022IX7ATM; 715 mt9v022->model = V4L2_IDENT_MT9V022IX7ATM;
716 mt9v022_ops.formats = mt9v022_monochrome_formats; 716 icd->formats = mt9v022_monochrome_formats;
717 if (mt9v022->client->dev.platform_data) 717 if (mt9v022->client->dev.platform_data)
718 mt9v022_ops.num_formats = ARRAY_SIZE(mt9v022_monochrome_formats); 718 icd->num_formats = ARRAY_SIZE(mt9v022_monochrome_formats);
719 else 719 else
720 mt9v022_ops.num_formats = 1; 720 icd->num_formats = 1;
721 } 721 }
722 722
723 if (ret >= 0) 723 if (ret >= 0)
@@ -773,8 +773,6 @@ static int mt9v022_probe(struct i2c_client *client)
773 i2c_set_clientdata(client, mt9v022); 773 i2c_set_clientdata(client, mt9v022);
774 774
775 icd = &mt9v022->icd; 775 icd = &mt9v022->icd;
776 icd->probe = mt9v022_video_probe;
777 icd->remove = mt9v022_video_remove;
778 icd->ops = &mt9v022_ops; 776 icd->ops = &mt9v022_ops;
779 icd->control = &client->dev; 777 icd->control = &client->dev;
780 icd->x_min = 1; 778 icd->x_min = 1;
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c
index 91e1ab36fe5d..4af38d444e0c 100644
--- a/drivers/media/video/soc_camera.c
+++ b/drivers/media/video/soc_camera.c
@@ -38,9 +38,9 @@ format_by_fourcc(struct soc_camera_device *icd, unsigned int fourcc)
38{ 38{
39 unsigned int i; 39 unsigned int i;
40 40
41 for (i = 0; i < icd->ops->num_formats; i++) 41 for (i = 0; i < icd->num_formats; i++)
42 if (icd->ops->formats[i].fourcc == fourcc) 42 if (icd->formats[i].fourcc == fourcc)
43 return icd->ops->formats + i; 43 return icd->formats + i;
44 return NULL; 44 return NULL;
45} 45}
46 46
@@ -384,10 +384,10 @@ static int soc_camera_enum_fmt_cap(struct file *file, void *priv,
384 384
385 WARN_ON(priv != file->private_data); 385 WARN_ON(priv != file->private_data);
386 386
387 if (f->index >= icd->ops->num_formats) 387 if (f->index >= icd->num_formats)
388 return -EINVAL; 388 return -EINVAL;
389 389
390 format = &icd->ops->formats[f->index]; 390 format = &icd->formats[f->index];
391 391
392 strlcpy(f->description, format->name, sizeof(f->description)); 392 strlcpy(f->description, format->name, sizeof(f->description));
393 f->pixelformat = format->fourcc; 393 f->pixelformat = format->fourcc;
@@ -701,7 +701,7 @@ static int soc_camera_probe(struct device *dev)
701 to_soc_camera_host(icd->dev.parent); 701 to_soc_camera_host(icd->dev.parent);
702 int ret; 702 int ret;
703 703
704 if (!icd->probe) 704 if (!icd->ops->probe)
705 return -ENODEV; 705 return -ENODEV;
706 706
707 /* We only call ->add() here to activate and probe the camera. 707 /* We only call ->add() here to activate and probe the camera.
@@ -710,7 +710,7 @@ static int soc_camera_probe(struct device *dev)
710 if (ret < 0) 710 if (ret < 0)
711 return ret; 711 return ret;
712 712
713 ret = icd->probe(icd); 713 ret = icd->ops->probe(icd);
714 if (ret >= 0) { 714 if (ret >= 0) {
715 const struct v4l2_queryctrl *qctrl; 715 const struct v4l2_queryctrl *qctrl;
716 716
@@ -731,8 +731,8 @@ static int soc_camera_remove(struct device *dev)
731{ 731{
732 struct soc_camera_device *icd = to_soc_camera_dev(dev); 732 struct soc_camera_device *icd = to_soc_camera_dev(dev);
733 733
734 if (icd->remove) 734 if (icd->ops->remove)
735 icd->remove(icd); 735 icd->ops->remove(icd);
736 736
737 return 0; 737 return 0;
738} 738}
@@ -928,7 +928,7 @@ int soc_camera_video_start(struct soc_camera_device *icd)
928 vdev->vidioc_s_register = soc_camera_s_register; 928 vdev->vidioc_s_register = soc_camera_s_register;
929#endif 929#endif
930 930
931 icd->current_fmt = &icd->ops->formats[0]; 931 icd->current_fmt = &icd->formats[0];
932 932
933 err = video_register_device(vdev, VFL_TYPE_GRABBER, vdev->minor); 933 err = video_register_device(vdev, VFL_TYPE_GRABBER, vdev->minor);
934 if (err < 0) { 934 if (err < 0) {
diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h
index 3e48e435b21a..7a2fa3ed849e 100644
--- a/include/media/soc_camera.h
+++ b/include/media/soc_camera.h
@@ -38,8 +38,8 @@ struct soc_camera_device {
38 struct soc_camera_ops *ops; 38 struct soc_camera_ops *ops;
39 struct video_device *vdev; 39 struct video_device *vdev;
40 const struct soc_camera_data_format *current_fmt; 40 const struct soc_camera_data_format *current_fmt;
41 int (*probe)(struct soc_camera_device *icd); 41 const struct soc_camera_data_format *formats;
42 void (*remove)(struct soc_camera_device *icd); 42 int num_formats;
43 struct module *owner; 43 struct module *owner;
44 /* soc_camera.c private count. Only accessed with video_lock held */ 44 /* soc_camera.c private count. Only accessed with video_lock held */
45 int use_count; 45 int use_count;
@@ -106,6 +106,8 @@ struct soc_camera_data_format {
106 106
107struct soc_camera_ops { 107struct soc_camera_ops {
108 struct module *owner; 108 struct module *owner;
109 int (*probe)(struct soc_camera_device *);
110 void (*remove)(struct soc_camera_device *);
109 int (*init)(struct soc_camera_device *); 111 int (*init)(struct soc_camera_device *);
110 int (*release)(struct soc_camera_device *); 112 int (*release)(struct soc_camera_device *);
111 int (*start_capture)(struct soc_camera_device *); 113 int (*start_capture)(struct soc_camera_device *);
@@ -121,8 +123,6 @@ struct soc_camera_ops {
121 int (*get_register)(struct soc_camera_device *, struct v4l2_register *); 123 int (*get_register)(struct soc_camera_device *, struct v4l2_register *);
122 int (*set_register)(struct soc_camera_device *, struct v4l2_register *); 124 int (*set_register)(struct soc_camera_device *, struct v4l2_register *);
123#endif 125#endif
124 const struct soc_camera_data_format *formats;
125 int num_formats;
126 int (*get_control)(struct soc_camera_device *, struct v4l2_control *); 126 int (*get_control)(struct soc_camera_device *, struct v4l2_control *);
127 int (*set_control)(struct soc_camera_device *, struct v4l2_control *); 127 int (*set_control)(struct soc_camera_device *, struct v4l2_control *);
128 const struct v4l2_queryctrl *controls; 128 const struct v4l2_queryctrl *controls;