Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab...
[pandora-kernel.git] / drivers / media / video / bt819.c
index 821af12..f9330e3 100644 (file)
 #include <linux/types.h>
 #include <linux/ioctl.h>
 #include <linux/delay.h>
-#include <asm/uaccess.h>
 #include <linux/i2c.h>
 #include <linux/i2c-id.h>
 #include <linux/videodev2.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-chip-ident.h>
-#include <media/v4l2-i2c-drv-legacy.h>
+#include <media/v4l2-i2c-drv.h>
+#include <media/bt819.h>
 
 MODULE_DESCRIPTION("Brooktree-819 video decoder driver");
 MODULE_AUTHOR("Mike Bernson & Dave Perks");
@@ -48,9 +48,6 @@ static int debug;
 module_param(debug, int, 0);
 MODULE_PARM_DESC(debug, "Debug level (0-1)");
 
-static unsigned short normal_i2c[] = { 0x8a >> 1, I2C_CLIENT_END };
-
-I2C_CLIENT_INSMOD;
 
 /* ----------------------------------------------------------------------- */
 
@@ -251,9 +248,13 @@ static int bt819_s_std(struct v4l2_subdev *sd, v4l2_std_id std)
        struct bt819 *decoder = to_bt819(sd);
        struct timing *timing = NULL;
 
-       v4l2_dbg(1, debug, sd, "set norm %llx\n", std);
+       v4l2_dbg(1, debug, sd, "set norm %llx\n", (unsigned long long)std);
+
+       if (sd->v4l2_dev == NULL || sd->v4l2_dev->notify == NULL)
+               v4l2_err(sd, "no notify found!\n");
 
        if (std & V4L2_STD_NTSC) {
+               v4l2_subdev_notify(sd, BT819_FIFO_RESET_LOW, 0);
                bt819_setbit(decoder, 0x01, 0, 1);
                bt819_setbit(decoder, 0x01, 1, 0);
                bt819_setbit(decoder, 0x01, 5, 0);
@@ -262,6 +263,7 @@ static int bt819_s_std(struct v4l2_subdev *sd, v4l2_std_id std)
                /* bt819_setbit(decoder, 0x1a,  5, 1); */
                timing = &timing_data[1];
        } else if (std & V4L2_STD_PAL) {
+               v4l2_subdev_notify(sd, BT819_FIFO_RESET_LOW, 0);
                bt819_setbit(decoder, 0x01, 0, 1);
                bt819_setbit(decoder, 0x01, 1, 1);
                bt819_setbit(decoder, 0x01, 5, 1);
@@ -270,7 +272,8 @@ static int bt819_s_std(struct v4l2_subdev *sd, v4l2_std_id std)
                /* bt819_setbit(decoder, 0x1a,  5, 0); */
                timing = &timing_data[0];
        } else {
-               v4l2_dbg(1, debug, sd, "unsupported norm %llx\n", std);
+               v4l2_dbg(1, debug, sd, "unsupported norm %llx\n",
+                               (unsigned long long)std);
                return -EINVAL;
        }
        bt819_write(decoder, 0x03,
@@ -285,20 +288,26 @@ static int bt819_s_std(struct v4l2_subdev *sd, v4l2_std_id std)
        bt819_write(decoder, 0x08, (timing->hscale >> 8) & 0xff);
        bt819_write(decoder, 0x09, timing->hscale & 0xff);
        decoder->norm = std;
+       v4l2_subdev_notify(sd, BT819_FIFO_RESET_HIGH, 0);
        return 0;
 }
 
-static int bt819_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route)
+static int bt819_s_routing(struct v4l2_subdev *sd,
+                          u32 input, u32 output, u32 config)
 {
        struct bt819 *decoder = to_bt819(sd);
 
-       v4l2_dbg(1, debug, sd, "set input %x\n", route->input);
+       v4l2_dbg(1, debug, sd, "set input %x\n", input);
 
-       if (route->input < 0 || route->input > 7)
+       if (input < 0 || input > 7)
                return -EINVAL;
 
-       if (decoder->input != route->input) {
-               decoder->input = route->input;
+       if (sd->v4l2_dev == NULL || sd->v4l2_dev->notify == NULL)
+               v4l2_err(sd, "no notify found!\n");
+
+       if (decoder->input != input) {
+               v4l2_subdev_notify(sd, BT819_FIFO_RESET_LOW, 0);
+               decoder->input = input;
                /* select mode */
                if (decoder->input == 0) {
                        bt819_setbit(decoder, 0x0b, 6, 0);
@@ -307,6 +316,7 @@ static int bt819_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *ro
                        bt819_setbit(decoder, 0x0b, 6, 1);
                        bt819_setbit(decoder, 0x1a, 1, 0);
                }
+               v4l2_subdev_notify(sd, BT819_FIFO_RESET_HIGH, 0);
        }
        return 0;
 }
@@ -428,11 +438,6 @@ static int bt819_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident
        return v4l2_chip_ident_i2c_client(client, chip, decoder->ident, 0);
 }
 
-static int bt819_command(struct i2c_client *client, unsigned cmd, void *arg)
-{
-       return v4l2_subdev_command(i2c_get_clientdata(client), cmd, arg);
-}
-
 /* ----------------------------------------------------------------------- */
 
 static const struct v4l2_subdev_core_ops bt819_core_ops = {
@@ -440,9 +445,6 @@ static const struct v4l2_subdev_core_ops bt819_core_ops = {
        .g_ctrl = bt819_g_ctrl,
        .s_ctrl = bt819_s_ctrl,
        .queryctrl = bt819_queryctrl,
-};
-
-static const struct v4l2_subdev_tuner_ops bt819_tuner_ops = {
        .s_std = bt819_s_std,
 };
 
@@ -455,7 +457,6 @@ static const struct v4l2_subdev_video_ops bt819_video_ops = {
 
 static const struct v4l2_subdev_ops bt819_ops = {
        .core = &bt819_core_ops,
-       .tuner = &bt819_tuner_ops,
        .video = &bt819_video_ops,
 };
 
@@ -537,8 +538,6 @@ MODULE_DEVICE_TABLE(i2c, bt819_id);
 
 static struct v4l2_i2c_driver_data v4l2_i2c_data = {
        .name = "bt819",
-       .driverid = I2C_DRIVERID_BT819,
-       .command = bt819_command,
        .probe = bt819_probe,
        .remove = bt819_remove,
        .id_table = bt819_id,