]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/kernel-video.git/commitdiff
i2c: fpdlink: camera: Add fpdlink camera driver
authorNikhil Devshatwar <nikhil.nd@ti.com>
Mon, 10 Mar 2014 18:12:08 +0000 (23:42 +0530)
committerArthur Philpott <arthur.philpott@ti.com>
Tue, 11 Mar 2014 23:25:13 +0000 (18:25 -0500)
It is possible to use output of FPDLink display as a camera
if it is connected to the deserializer of JAMR3 board.
Deserializer output is given to Vin1a

As, VIP can communicate with only subdevices, we need a subdevice to
use the fpdlink display as camera.

This patch adds a device tree node for the camera and the compatible driver.
The i2c driver for the fpdlink camera only registers a v4l2 subdevice
The display can be looped back from the same EVM or can come externally
via the FPDLink. In any case, deserializer configuration is done at the
remote end (serializer side), so this driver won't configure the deserializer.

Change-Id: I910aff26ff31444c38afda8fe5acd59ee2d8ec8f
Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
arch/arm/boot/dts/dra7-evm.dts
drivers/media/i2c/Kconfig
drivers/media/i2c/Makefile
drivers/media/i2c/fpdlink.c [new file with mode: 0644]

index 79e24b4fe1800aefa19f2130bf80b36c63532d68..bc062a1e16314b87baab946b5364aa82d24343da 100644 (file)
                ovnode = <&i2c2>;
        };
 
+       fpdlink_camera {
+               compatible = "ti,fpdlink";
+               reg = <0x20>;
+               port {
+                       cam_fpdlink: endpoint {
+                               hsync-active = <1>;
+                               vsync-active = <1>;
+                               pclk-sample = <0>;
+                               bus-width = <24>;
+                       };
+               };
+       };
+
        ov10633@37 {
                compatible = "omnivision,ov10633";
                reg = <0x37>;
                TO enable RGB camera, uncomment this
                pinctrl-0 = <&vin1a_pins &vin1a_d16_d23_pins>;
        */
-       pinctrl-0 = <&vin1a_pins &vin2a_pins>;
+       pinctrl-0 = <&vin1a_pins &vin1a_d16_d23_pins>;
 };
 
 &vip2 {
 };
 
 &vin1a {
+       endpoint@4 {
+               slave-mode;
+               remote-endpoint = <&cam_fpdlink>;
+       };
        endpoint@0 {
                slave-mode;
                remote-endpoint = <&onboardLI>;
index ff9845c8eff218253e0b188665e638fefc4bed04..0c9490e49cf9fefb3621c7c2d8eb5a06c496ca71 100644 (file)
@@ -433,6 +433,17 @@ config VIDEO_OV1063X
          This is a Video4Linux2 sensor-level driver for the OmniVision
          OV1063X Sensor.
 
+config VIDEO_CAM_FPDLINK
+        tristate "FPDLink display camera"
+        depends on I2C && VIDEO_V4L2
+        depends on MEDIA_CAMERA_SUPPORT
+        ---help---
+          This is not a camera, it is the fpdlink display loopbacked
+         using deserializer.
+
+         This is a dummy driver which just allows to connect the fpdlink
+         display output as a camera device.
+
 config VIDEO_TVP5158
         tristate "Analog video decoder TVP5158 support NTSC/PAL"
         depends on I2C && VIDEO_V4L2
index 90d46063124e5db52b5782297e453e3dc7dbc919..8c76302a69f2d8988320e175f8efc21689ae3a7a 100644 (file)
@@ -49,6 +49,7 @@ obj-$(CONFIG_VIDEO_UPD64083) += upd64083.o
 obj-$(CONFIG_VIDEO_OV7670)     += ov7670.o
 obj-$(CONFIG_VIDEO_OV1063X)    += ov1063x.o
 obj-$(CONFIG_VIDEO_TVP5158)     += tvp5158.o
+obj-$(CONFIG_VIDEO_CAM_FPDLINK)     += fpdlink.o
 obj-$(CONFIG_VIDEO_TCM825X) += tcm825x.o
 obj-$(CONFIG_VIDEO_TVEEPROM) += tveeprom.o
 obj-$(CONFIG_VIDEO_MT9M032) += mt9m032.o
diff --git a/drivers/media/i2c/fpdlink.c b/drivers/media/i2c/fpdlink.c
new file mode 100644 (file)
index 0000000..42e8bca
--- /dev/null
@@ -0,0 +1,137 @@
+#include <linux/i2c.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+#include <linux/v4l2-mediabus.h>
+#include <linux/videodev2.h>
+
+#include <media/v4l2-subdev.h>
+#include <media/v4l2-async.h>
+#include <media/v4l2-common.h>
+#include <media/v4l2-ctrls.h>
+
+#include <linux/pm_runtime.h>
+
+struct fpdlink_color_format {
+       enum v4l2_mbus_pixelcode code;
+       enum v4l2_colorspace colorspace;
+};
+
+static const struct fpdlink_color_format fpdlink_cfmts[] = {
+       {
+               .code           = V4L2_MBUS_FMT_SBGGR8_1X8,
+               .colorspace     = V4L2_COLORSPACE_SRGB,
+       },
+};
+
+static int fpdlink_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
+                       enum v4l2_mbus_pixelcode *code)
+{
+       if (index >= ARRAY_SIZE(fpdlink_cfmts))
+               return -EINVAL;
+
+       *code = fpdlink_cfmts[0].code;
+
+       return 0;
+}
+
+static int fpdlink_g_fmt(struct v4l2_subdev *sd,
+               struct v4l2_mbus_framefmt *mf)
+{
+       return 0;
+}
+
+static int fpdlink_try_fmt(struct v4l2_subdev *sd,
+               struct v4l2_mbus_framefmt *mf)
+{
+       return 0;
+}
+
+static int fpdlink_s_fmt(struct v4l2_subdev *sd,
+               struct v4l2_mbus_framefmt *mf)
+{
+       return 0;
+}
+
+static int fpdlink_s_stream(struct v4l2_subdev *sd, int enable)
+{
+       return 0;
+}
+
+static struct v4l2_subdev_video_ops fpdlink_video_ops = {
+       .enum_mbus_fmt  = fpdlink_enum_fmt,
+       .g_mbus_fmt     = fpdlink_g_fmt,
+       .try_mbus_fmt   = fpdlink_try_fmt,
+       .s_mbus_fmt     = fpdlink_s_fmt,
+       .s_stream       = fpdlink_s_stream,
+};
+
+static struct v4l2_subdev_ops fpdlink_subdev_ops = {
+       .video          = &fpdlink_video_ops,
+};
+
+static const struct i2c_device_id fpdlink_id[] = {
+       { "ti,fpdlink", 0 },
+       { }
+};
+MODULE_DEVICE_TABLE(i2c, fpdlink_id);
+
+static const struct of_device_id fpdlink_dt_id[] = {
+       {
+       .compatible   = "ti,fpdlink"
+       },
+       {
+       }
+};
+
+static int fpdlink_probe(struct i2c_client *client,
+                        const struct i2c_device_id *did)
+{
+       struct v4l2_subdev *sd;
+       int ret = -1;
+
+       sd = devm_kzalloc(&client->dev, sizeof(*sd), GFP_KERNEL);
+       if (!sd)
+               return -ENOMEM;
+
+       v4l2_i2c_subdev_init(sd, client, &fpdlink_subdev_ops);
+
+       /* V4l2 asyn subdev register */
+       sd->dev = &client->dev;
+       ret = v4l2_async_register_subdev(sd);
+       if (!ret) {
+               i2c_set_clientdata(client, sd);
+               v4l2_info(sd, "Camera sensor driver registered\n");
+               pm_runtime_enable(&client->dev);
+       }
+
+       return ret;
+}
+
+static int fpdlink_remove(struct i2c_client *client)
+{
+       struct v4l2_subdev *sd = i2c_get_clientdata(client);
+
+       if (sd)
+               v4l2_async_unregister_subdev(sd);
+
+       return 0;
+}
+
+static struct i2c_driver fpdlink_i2c_driver = {
+       .driver = {
+               .owner  = THIS_MODULE,
+               .name   = "fpdlink",
+               .of_match_table = fpdlink_dt_id,
+       },
+       .probe    = fpdlink_probe,
+       .remove   = fpdlink_remove,
+       .id_table = fpdlink_id,
+};
+
+module_i2c_driver(fpdlink_i2c_driver);
+
+MODULE_DESCRIPTION("FPDLink display interface");
+MODULE_AUTHOR("Nikhil Devshatwar");
+MODULE_LICENSE("GPL v2");