]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/media/video/wm8775.c
Merge master.kernel.org:/pub/scm/linux/kernel/git/davej/agpgart
[mv-sheeva.git] / drivers / media / video / wm8775.c
index a1b6a427ab745b62b872d0682fc0d72c68621c23..d81a88bbe43d02a8aac3f61a575facb07153615a 100644 (file)
 #include <linux/i2c.h>
 #include <linux/i2c-id.h>
 #include <linux/videodev.h>
-#include <media/audiochip.h>
+#include <media/v4l2-common.h>
 
 MODULE_DESCRIPTION("wm8775 driver");
 MODULE_AUTHOR("Ulf Eklund, Hans Verkuil");
 MODULE_LICENSE("GPL");
 
-#define wm8775_err(fmt, arg...) do { \
-       printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->driver.name, \
-              i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
-#define wm8775_info(fmt, arg...) do { \
-       printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->driver.name, \
-              i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
-
-
 static unsigned short normal_i2c[] = { 0x36 >> 1, I2C_CLIENT_END };
 
 
@@ -69,7 +61,7 @@ static int wm8775_write(struct i2c_client *client, int reg, u16 val)
        int i;
 
        if (reg < 0 || reg >= TOT_REGS) {
-               wm8775_err("Invalid register R%d\n", reg);
+               v4l_err(client, "Invalid register R%d\n", reg);
                return -1;
        }
 
@@ -79,7 +71,7 @@ static int wm8775_write(struct i2c_client *client, int reg, u16 val)
                        return 0;
                }
        }
-       wm8775_err("I2C: cannot write %03x to register R%d\n", val, reg);
+       v4l_err(client, "I2C: cannot write %03x to register R%d\n", val, reg);
        return -1;
 }
 
@@ -87,21 +79,26 @@ static int wm8775_command(struct i2c_client *client, unsigned int cmd,
                          void *arg)
 {
        struct wm8775_state *state = i2c_get_clientdata(client);
-       struct v4l2_audio *input = arg;
+       struct v4l2_routing *route = arg;
        struct v4l2_control *ctrl = arg;
 
        switch (cmd) {
-       case VIDIOC_S_AUDIO:
+       case VIDIOC_INT_G_AUDIO_ROUTING:
+               route->input = state->input;
+               route->output = 0;
+               break;
+
+       case VIDIOC_INT_S_AUDIO_ROUTING:
                /* There are 4 inputs and one output. Zero or more inputs
                   are multiplexed together to the output. Hence there are
                   16 combinations.
                   If only one input is active (the normal case) then the
                   input values 1, 2, 4 or 8 should be used. */
-               if (input->index > 15) {
-                       wm8775_err("Invalid input %d.\n", input->index);
+               if (route->input > 15) {
+                       v4l_err(client, "Invalid input %d.\n", route->input);
                        return -EINVAL;
                }
-               state->input = input->index;
+               state->input = route->input;
                if (state->muted)
                        break;
                wm8775_write(client, R21, 0x0c0);
@@ -110,11 +107,6 @@ static int wm8775_command(struct i2c_client *client, unsigned int cmd,
                wm8775_write(client, R21, 0x100 + state->input);
                break;
 
-       case VIDIOC_G_AUDIO:
-               memset(input, 0, sizeof(*input));
-               input->index = state->input;
-               break;
-
        case VIDIOC_G_CTRL:
                if (ctrl->id != V4L2_CID_AUDIO_MUTE)
                        return -EINVAL;
@@ -133,7 +125,7 @@ static int wm8775_command(struct i2c_client *client, unsigned int cmd,
                break;
 
        case VIDIOC_LOG_STATUS:
-               wm8775_info("Input: %d%s\n", state->input,
+               v4l_info(client, "Input: %d%s\n", state->input,
                            state->muted ? " (muted)" : "");
                break;
 
@@ -174,17 +166,16 @@ static int wm8775_attach(struct i2c_adapter *adapter, int address, int kind)
        if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
                return 0;
 
-       client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
+       client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
        if (client == 0)
                return -ENOMEM;
 
-       memset(client, 0, sizeof(struct i2c_client));
        client->addr = address;
        client->adapter = adapter;
        client->driver = &i2c_driver;
        snprintf(client->name, sizeof(client->name) - 1, "wm8775");
 
-       wm8775_info("chip found @ 0x%x (%s)\n", address << 1, adapter->name);
+       v4l_info(client, "chip found @ 0x%x (%s)\n", address << 1, adapter->name);
 
        state = kmalloc(sizeof(struct wm8775_state), GFP_KERNEL);
        if (state == NULL) {
@@ -245,12 +236,10 @@ static struct i2c_driver i2c_driver = {
        .driver = {
                .name = "wm8775",
        },
-
-       .id = I2C_DRIVERID_WM8775,
-
+       .id             = I2C_DRIVERID_WM8775,
        .attach_adapter = wm8775_probe,
-       .detach_client = wm8775_detach,
-       .command = wm8775_command,
+       .detach_client  = wm8775_detach,
+       .command        = wm8775_command,
 };