~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to drivers/media/video/tlv320aic23b.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno
  • Date: 2011-06-07 12:14:05 UTC
  • mfrom: (43.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20110607121405-i3h1rd7nrnd2b73h
Tags: 2.6.39-2
[ Ben Hutchings ]
* [x86] Enable BACKLIGHT_APPLE, replacing BACKLIGHT_MBP_NVIDIA
  (Closes: #627492)
* cgroups: Disable memory resource controller by default. Allow it
  to be enabled using kernel parameter 'cgroup_enable=memory'.
* rt2800usb: Enable support for more USB devices including
  Linksys WUSB600N (Closes: #596626) (this change was accidentally
  omitted from 2.6.39-1)
* [x86] Remove Celeron from list of processors supporting PAE. Most
  'Celeron M' models do not.
* Update debconf template translations:
  - Swedish (Martin Bagge) (Closes: #628932)
  - French (David Prévot) (Closes: #628191)
* aufs: Update for 2.6.39 (Closes: #627837)
* Add stable 2.6.39.1, including:
  - ext4: dont set PageUptodate in ext4_end_bio()
  - pata_cmd64x: fix boot crash on parisc (Closes: #622997, #622745)
  - ext3: Fix fs corruption when make_indexed_dir() fails
  - netfilter: nf_ct_sip: validate Content-Length in TCP SIP messages
  - sctp: fix race between sctp_bind_addr_free() and
    sctp_bind_addr_conflict()
  - sctp: fix memory leak of the ASCONF queue when free asoc
  - md/bitmap: fix saving of events_cleared and other state
  - cdc_acm: Fix oops when Droids MuIn LCD is connected
  - cx88: Fix conversion from BKL to fine-grained locks (Closes: #619827)
  - keys: Set cred->user_ns in key_replace_session_keyring (CVE-2011-2184)
  - tmpfs: fix race between truncate and writepage
  - nfs41: Correct offset for LAYOUTCOMMIT
  - xen/mmu: fix a race window causing leave_mm BUG()
  - ext4: fix possible use-after-free in ext4_remove_li_request()
  For the complete list of changes, see:
   http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.39.1
* Bump ABI to 2
* netfilter: Enable IP_SET, IP_SET_BITMAP_IP, IP_SET_BITMAP_IPMAC,
  IP_SET_BITMAP_PORT, IP_SET_HASH_IP, IP_SET_HASH_IPPORT,
  IP_SET_HASH_IPPORTIP, IP_SET_HASH_IPPORTNET, IP_SET_HASH_NET,
  IP_SET_HASH_NETPORT, IP_SET_LIST_SET, NETFILTER_XT_SET as modules
  (Closes: #629401)

[ Aurelien Jarno ]
* [mipsel/loongson-2f] Disable_SCSI_LPFC to workaround GCC ICE.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include <linux/i2c.h>
32
32
#include <linux/videodev2.h>
33
33
#include <media/v4l2-device.h>
 
34
#include <media/v4l2-ctrls.h>
34
35
 
35
36
MODULE_DESCRIPTION("tlv320aic23b driver");
36
37
MODULE_AUTHOR("Scott Alfter, Ulf Eklund, Hans Verkuil");
41
42
 
42
43
struct tlv320aic23b_state {
43
44
        struct v4l2_subdev sd;
44
 
        u8 muted;
 
45
        struct v4l2_ctrl_handler hdl;
45
46
};
46
47
 
47
48
static inline struct tlv320aic23b_state *to_state(struct v4l2_subdev *sd)
49
50
        return container_of(sd, struct tlv320aic23b_state, sd);
50
51
}
51
52
 
 
53
static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
 
54
{
 
55
        return &container_of(ctrl->handler, struct tlv320aic23b_state, hdl)->sd;
 
56
}
 
57
 
52
58
static int tlv320aic23b_write(struct v4l2_subdev *sd, int reg, u16 val)
53
59
{
54
60
        struct i2c_client *client = v4l2_get_subdevdata(sd);
85
91
        return 0;
86
92
}
87
93
 
88
 
static int tlv320aic23b_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
89
 
{
90
 
        struct tlv320aic23b_state *state = to_state(sd);
91
 
 
92
 
        if (ctrl->id != V4L2_CID_AUDIO_MUTE)
93
 
                return -EINVAL;
94
 
        ctrl->value = state->muted;
95
 
        return 0;
96
 
}
97
 
 
98
 
static int tlv320aic23b_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
99
 
{
100
 
        struct tlv320aic23b_state *state = to_state(sd);
101
 
 
102
 
        if (ctrl->id != V4L2_CID_AUDIO_MUTE)
103
 
                return -EINVAL;
104
 
        state->muted = ctrl->value;
105
 
        tlv320aic23b_write(sd, 0, 0x180); /* mute both channels */
106
 
        /* set gain on both channels to +3.0 dB */
107
 
        if (!state->muted)
108
 
                tlv320aic23b_write(sd, 0, 0x119);
109
 
        return 0;
 
94
static int tlv320aic23b_s_ctrl(struct v4l2_ctrl *ctrl)
 
95
{
 
96
        struct v4l2_subdev *sd = to_sd(ctrl);
 
97
 
 
98
        switch (ctrl->id) {
 
99
        case V4L2_CID_AUDIO_MUTE:
 
100
                tlv320aic23b_write(sd, 0, 0x180); /* mute both channels */
 
101
                /* set gain on both channels to +3.0 dB */
 
102
                if (!ctrl->val)
 
103
                        tlv320aic23b_write(sd, 0, 0x119);
 
104
                return 0;
 
105
        }
 
106
        return -EINVAL;
110
107
}
111
108
 
112
109
static int tlv320aic23b_log_status(struct v4l2_subdev *sd)
113
110
{
114
111
        struct tlv320aic23b_state *state = to_state(sd);
115
112
 
116
 
        v4l2_info(sd, "Input: %s\n", state->muted ? "muted" : "active");
 
113
        v4l2_ctrl_handler_log_status(&state->hdl, sd->name);
117
114
        return 0;
118
115
}
119
116
 
120
117
/* ----------------------------------------------------------------------- */
121
118
 
 
119
static const struct v4l2_ctrl_ops tlv320aic23b_ctrl_ops = {
 
120
        .s_ctrl = tlv320aic23b_s_ctrl,
 
121
};
 
122
 
122
123
static const struct v4l2_subdev_core_ops tlv320aic23b_core_ops = {
123
124
        .log_status = tlv320aic23b_log_status,
124
 
        .g_ctrl = tlv320aic23b_g_ctrl,
125
 
        .s_ctrl = tlv320aic23b_s_ctrl,
 
125
        .g_ext_ctrls = v4l2_subdev_g_ext_ctrls,
 
126
        .try_ext_ctrls = v4l2_subdev_try_ext_ctrls,
 
127
        .s_ext_ctrls = v4l2_subdev_s_ext_ctrls,
 
128
        .g_ctrl = v4l2_subdev_g_ctrl,
 
129
        .s_ctrl = v4l2_subdev_s_ctrl,
 
130
        .queryctrl = v4l2_subdev_queryctrl,
 
131
        .querymenu = v4l2_subdev_querymenu,
126
132
};
127
133
 
128
134
static const struct v4l2_subdev_audio_ops tlv320aic23b_audio_ops = {
161
167
                return -ENOMEM;
162
168
        sd = &state->sd;
163
169
        v4l2_i2c_subdev_init(sd, client, &tlv320aic23b_ops);
164
 
        state->muted = 0;
165
170
 
166
171
        /* Initialize tlv320aic23b */
167
172
 
177
182
        tlv320aic23b_write(sd, 8, 0x000);
178
183
        /* activate digital interface */
179
184
        tlv320aic23b_write(sd, 9, 0x001);
 
185
 
 
186
        v4l2_ctrl_handler_init(&state->hdl, 1);
 
187
        v4l2_ctrl_new_std(&state->hdl, &tlv320aic23b_ctrl_ops,
 
188
                        V4L2_CID_AUDIO_MUTE, 0, 1, 1, 0);
 
189
        sd->ctrl_handler = &state->hdl;
 
190
        if (state->hdl.error) {
 
191
                int err = state->hdl.error;
 
192
 
 
193
                v4l2_ctrl_handler_free(&state->hdl);
 
194
                kfree(state);
 
195
                return err;
 
196
        }
 
197
        v4l2_ctrl_handler_setup(&state->hdl);
180
198
        return 0;
181
199
}
182
200
 
183
201
static int tlv320aic23b_remove(struct i2c_client *client)
184
202
{
185
203
        struct v4l2_subdev *sd = i2c_get_clientdata(client);
 
204
        struct tlv320aic23b_state *state = to_state(sd);
186
205
 
187
206
        v4l2_device_unregister_subdev(sd);
188
 
        kfree(to_state(sd));
 
207
        v4l2_ctrl_handler_free(&state->hdl);
 
208
        kfree(state);
189
209
        return 0;
190
210
}
191
211