aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/pvrusb2/pvrusb2-wm8775.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/pvrusb2/pvrusb2-wm8775.c')
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-wm8775.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-wm8775.c b/drivers/media/video/pvrusb2/pvrusb2-wm8775.c
index 7794c34c355e..66b4d36ef765 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-wm8775.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-wm8775.c
@@ -50,15 +50,21 @@ static void set_input(struct pvr2_v4l_wm8775 *ctxt)
50{ 50{
51 struct v4l2_routing route; 51 struct v4l2_routing route;
52 struct pvr2_hdw *hdw = ctxt->hdw; 52 struct pvr2_hdw *hdw = ctxt->hdw;
53 int msk = 0;
54 53
55 memset(&route,0,sizeof(route)); 54 memset(&route,0,sizeof(route));
56 55
57 pvr2_trace(PVR2_TRACE_CHIPS,"i2c wm8775 set_input(val=%d msk=0x%x)", 56 switch(hdw->input_val) {
58 hdw->input_val,msk); 57 case PVR2_CVAL_INPUT_RADIO:
58 route.input = 1;
59 break;
60 default:
61 /* All other cases just use the second input */
62 route.input = 2;
63 break;
64 }
65 pvr2_trace(PVR2_TRACE_CHIPS,"i2c wm8775 set_input(val=%d route=0x%x)",
66 hdw->input_val,route.input);
59 67
60 // Always point to input #1 no matter what
61 route.input = 2;
62 pvr2_i2c_client_cmd(ctxt->client,VIDIOC_INT_S_AUDIO_ROUTING,&route); 68 pvr2_i2c_client_cmd(ctxt->client,VIDIOC_INT_S_AUDIO_ROUTING,&route);
63} 69}
64 70
@@ -99,8 +105,7 @@ static int wm8775_check(struct pvr2_v4l_wm8775 *ctxt)
99 unsigned long msk; 105 unsigned long msk;
100 unsigned int idx; 106 unsigned int idx;
101 107
102 for (idx = 0; idx < sizeof(wm8775_ops)/sizeof(wm8775_ops[0]); 108 for (idx = 0; idx < ARRAY_SIZE(wm8775_ops); idx++) {
103 idx++) {
104 msk = 1 << idx; 109 msk = 1 << idx;
105 if (ctxt->stale_mask & msk) continue; 110 if (ctxt->stale_mask & msk) continue;
106 if (wm8775_ops[idx].check(ctxt)) { 111 if (wm8775_ops[idx].check(ctxt)) {
@@ -116,8 +121,7 @@ static void wm8775_update(struct pvr2_v4l_wm8775 *ctxt)
116 unsigned long msk; 121 unsigned long msk;
117 unsigned int idx; 122 unsigned int idx;
118 123
119 for (idx = 0; idx < sizeof(wm8775_ops)/sizeof(wm8775_ops[0]); 124 for (idx = 0; idx < ARRAY_SIZE(wm8775_ops); idx++) {
120 idx++) {
121 msk = 1 << idx; 125 msk = 1 << idx;
122 if (!(ctxt->stale_mask & msk)) continue; 126 if (!(ctxt->stale_mask & msk)) continue;
123 ctxt->stale_mask &= ~msk; 127 ctxt->stale_mask &= ~msk;
@@ -140,16 +144,14 @@ int pvr2_i2c_wm8775_setup(struct pvr2_hdw *hdw,struct pvr2_i2c_client *cp)
140 144
141 if (cp->handler) return 0; 145 if (cp->handler) return 0;
142 146
143 ctxt = kmalloc(sizeof(*ctxt),GFP_KERNEL); 147 ctxt = kzalloc(sizeof(*ctxt),GFP_KERNEL);
144 if (!ctxt) return 0; 148 if (!ctxt) return 0;
145 memset(ctxt,0,sizeof(*ctxt));
146 149
147 ctxt->handler.func_data = ctxt; 150 ctxt->handler.func_data = ctxt;
148 ctxt->handler.func_table = &hfuncs; 151 ctxt->handler.func_table = &hfuncs;
149 ctxt->client = cp; 152 ctxt->client = cp;
150 ctxt->hdw = hdw; 153 ctxt->hdw = hdw;
151 ctxt->stale_mask = (1 << (sizeof(wm8775_ops)/ 154 ctxt->stale_mask = (1 << ARRAY_SIZE(wm8775_ops)) - 1;
152 sizeof(wm8775_ops[0]))) - 1;
153 cp->handler = &ctxt->handler; 155 cp->handler = &ctxt->handler;
154 pvr2_trace(PVR2_TRACE_CHIPS,"i2c 0x%x wm8775 V4L2 handler set up", 156 pvr2_trace(PVR2_TRACE_CHIPS,"i2c 0x%x wm8775 V4L2 handler set up",
155 cp->client->addr); 157 cp->client->addr);