X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fmedia%2Fvideo%2Fwm8775.c;h=9f7e894ef962cdc4d76baec111aacb99fa700261;hb=7578634990fb47cc30083fbd812689aa6deacfc0;hp=20b4ec93d7c982202bb8655fd6eb6f319cd7e9fa;hpb=fac9e89999a12f378112fe93764b30196bc03f46;p=pandora-kernel.git diff --git a/drivers/media/video/wm8775.c b/drivers/media/video/wm8775.c index 20b4ec93d7c9..9f7e894ef962 100644 --- a/drivers/media/video/wm8775.c +++ b/drivers/media/video/wm8775.c @@ -33,6 +33,7 @@ #include #include #include +#include MODULE_DESCRIPTION("wm8775 driver"); MODULE_AUTHOR("Ulf Eklund, Hans Verkuil"); @@ -79,21 +80,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) { - v4l_err(client, "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); @@ -102,11 +108,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; @@ -124,6 +125,9 @@ static int wm8775_command(struct i2c_client *client, unsigned int cmd, wm8775_write(client, R21, 0x100 + state->input); break; + case VIDIOC_G_CHIP_IDENT: + return v4l2_chip_ident_i2c_client(client, arg, V4L2_IDENT_WM8775, 0); + case VIDIOC_LOG_STATUS: v4l_info(client, "Input: %d%s\n", state->input, state->muted ? " (muted)" : ""); @@ -166,11 +170,10 @@ 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; @@ -219,12 +222,14 @@ static int wm8775_probe(struct i2c_adapter *adapter) static int wm8775_detach(struct i2c_client *client) { + struct wm8775_state *state = i2c_get_clientdata(client); int err; err = i2c_detach_client(client); if (err) { return err; } + kfree(state); kfree(client); return 0; @@ -237,12 +242,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, };