21 #include <linux/errno.h>
23 #include <linux/i2c.h>
25 #include <linux/module.h>
26 #include <linux/slab.h>
27 #include <linux/types.h>
28 #include <linux/videodev2.h>
38 #define VGA_HEIGHT 480
39 #define QVGA_WIDTH 320
40 #define QVGA_HEIGHT 240
41 #define QQVGA_WIDTH 160
42 #define QQVGA_HEIGHT 120
44 #define CIF_HEIGHT 288
45 #define QCIF_WIDTH 176
46 #define QCIF_HEIGHT 144
47 #define QQCIF_WIDTH 88
48 #define QQCIF_HEIGHT 72
50 #define MAX_FRAME_RATE 30
56 struct v4l2_mbus_framefmt
fmt;
60 static const struct vs6624_format {
63 } vs6624_formats[] = {
78 static struct v4l2_mbus_framefmt vs6624_default_fmt = {
86 static const u16 vs6624_p1[] = {
412 static const u16 vs6624_p2[] = {
418 static const u16 vs6624_run_setup[] = {
460 static const u16 vs6624_default[] = {
538 while (*regs != 0x00) {
542 vs6624_write(sd, reg, data);
577 *code = vs6624_formats[
index].mbus_code;
581 static int vs6624_try_mbus_fmt(
struct v4l2_subdev *sd,
582 struct v4l2_mbus_framefmt *
fmt)
586 for (index = 0; index <
ARRAY_SIZE(vs6624_formats); index++)
587 if (vs6624_formats[index].mbus_code == fmt->code)
592 fmt->code = vs6624_formats[0].mbus_code;
600 fmt->width = fmt->width & (~3);
601 fmt->height = fmt->height & (~3);
603 fmt->colorspace = vs6624_formats[
index].colorspace;
607 static int vs6624_s_mbus_fmt(
struct v4l2_subdev *sd,
608 struct v4l2_mbus_framefmt *fmt)
610 struct vs6624 *sensor = to_vs6624(sd);
613 ret = vs6624_try_mbus_fmt(sd, fmt);
662 static int vs6624_g_mbus_fmt(
struct v4l2_subdev *sd,
663 struct v4l2_mbus_framefmt *fmt)
665 struct vs6624 *sensor = to_vs6624(sd);
673 struct vs6624 *sensor = to_vs6624(sd);
679 memset(cp, 0,
sizeof(*cp));
688 struct vs6624 *sensor = to_vs6624(sd);
725 static int vs6624_g_chip_ident(
struct v4l2_subdev *sd,
737 #ifdef CONFIG_VIDEO_ADV_DEBUG
740 struct i2c_client *client = v4l2_get_subdevdata(sd);
746 reg->
val = vs6624_read(sd, reg->
reg & 0xffff);
753 struct i2c_client *client = v4l2_get_subdevdata(sd);
759 vs6624_write(sd, reg->
reg & 0xffff, reg->
val & 0xff);
765 .s_ctrl = vs6624_s_ctrl,
769 .g_chip_ident = vs6624_g_chip_ident,
770 #ifdef CONFIG_VIDEO_ADV_DEBUG
771 .g_register = vs6624_g_register,
772 .s_register = vs6624_s_register,
777 .enum_mbus_fmt = vs6624_enum_mbus_fmt,
778 .try_mbus_fmt = vs6624_try_mbus_fmt,
779 .s_mbus_fmt = vs6624_s_mbus_fmt,
780 .g_mbus_fmt = vs6624_g_mbus_fmt,
781 .s_parm = vs6624_s_parm,
782 .g_parm = vs6624_g_parm,
783 .s_stream = vs6624_s_stream,
787 .core = &vs6624_core_ops,
788 .video = &vs6624_video_ops,
804 ce = client->
dev.platform_data;
810 v4l_err(client,
"failed to request GPIO %d\n", *ce);
817 sensor = kzalloc(
sizeof(*sensor),
GFP_KERNEL);
818 if (sensor ==
NULL) {
826 vs6624_writeregs(sd, vs6624_p1);
830 vs6624_writeregs(sd, vs6624_p2);
832 vs6624_writeregs(sd, vs6624_default);
834 vs6624_writeregs(sd, vs6624_run_setup);
847 sensor->
fmt = vs6624_default_fmt;
850 v4l_info(client,
"chip found @ 0x%02x (%s)\n",
886 struct v4l2_subdev *sd = i2c_get_clientdata(client);
887 struct vs6624 *sensor = to_vs6624(sd);
908 .probe = vs6624_probe,
910 .id_table = vs6624_id,
913 static __init int vs6624_init(
void)
915 return i2c_add_driver(&vs6624_driver);
918 static __exit void vs6624_exit(
void)