Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Revert "[media] staging: media: go7007: Adlink MPG24 board issues"

This patch were applied by mistake, as it were rejected by Don, who
requested it to be broken into per-change patches.

This reverts commit 0982db20aba5fd124bb5942d679d8732478e992a.

Cc: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Volokh Konstantin <volokh84@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

+164 -407
-18
drivers/staging/media/go7007/README
··· 5 5 and added to the build. 6 6 - testing? 7 7 - handle churn in v4l layer. 8 - - Some features for wis-tw2804 subdev control (comb filter,motion detector sensitive & mask,more over...) 9 - - go7007-v4l2.c need rewrite with new v4l2 style without nonstandart IO controls (set detector & bitrate) 10 - 11 - 05/05/2012 3.4.0-rc+: 12 - Changes: 13 - - When go7007 reset device, i2c was not worked (need rewrite GPIO5) 14 - - As wis2804 has i2c_addr=0x00/*really*/, so Need set I2C_CLIENT_TEN flag for validity 15 - - Some main nonzero initialization, rewrites with kzalloc instead kmalloc 16 - - STATUS_SHUTDOWN was placed in incorrect place, so if firmware wasn`t loaded, we 17 - failed v4l2_device_unregister with kernel panic (OOPS) 18 - - Some new v4l2 style features as call_all(...s_stream...) for using subdev calls 19 - - wis-tw2804.ko module code was incompatible with 3.4.x branch in initialization v4l2_subdev parts. 20 - now i2c_get_clientdata(...) contains v4l2_subdev struct instead non standart wis_tw2804 struct 21 - 22 - Adds: 23 - - Additional chipset wis2804 controls with: gain,auto gain,inputs[0,1],color kill,chroma gain,gain balances, 24 - for all 4 channels (from tw2804.pdf) 25 - - Power control for each 4 ADC up when s_stream(...,1), down otherwise in wis-tw2804 module 26 8 27 9 Please send patchs to Greg Kroah-Hartman <greg@kroah.com> and Cc: Ross 28 10 Cohen <rcohen@snurgle.org> as well.
+9 -18
drivers/staging/media/go7007/go7007-driver.c
··· 173 173 go7007_write_addr(go, 0x3c82, 0x0001); 174 174 go7007_write_addr(go, 0x3c80, 0x00fe); 175 175 } 176 - if (go->board_id == GO7007_BOARDID_ADLINK_MPG24) { 177 - /* set GPIO5 to be an output, currently low */ 178 - go7007_write_addr(go, 0x3c82, 0x0000); 179 - go7007_write_addr(go, 0x3c80, 0x00df); 180 - } 181 176 return 0; 182 177 } 183 178 ··· 192 197 /* 193 198 * Attempt to instantiate an I2C client by ID, probably loading a module. 194 199 */ 195 - static int init_i2c_module(struct i2c_adapter *adapter, const struct go_i2c *const i2c) 200 + static int init_i2c_module(struct i2c_adapter *adapter, const char *type, 201 + int addr) 196 202 { 197 203 struct go7007 *go = i2c_get_adapdata(adapter); 198 204 struct v4l2_device *v4l2_dev = &go->v4l2_dev; 199 - struct i2c_board_info info; 200 205 201 - memset(&info, 0, sizeof(info)); 202 - strlcpy(info.type, i2c->type, sizeof(info.type)); 203 - info.addr = i2c->addr; 204 - 205 - if (i2c->id == I2C_DRIVERID_WIS_TW2804) 206 - info.flags |= I2C_CLIENT_TEN; 207 - if (v4l2_i2c_new_subdev_board(v4l2_dev, adapter, &info, NULL)) 206 + if (v4l2_i2c_new_subdev(v4l2_dev, adapter, type, addr, NULL)) 208 207 return 0; 209 208 210 - printk(KERN_INFO "go7007: probing for module i2c:%s failed\n", i2c->type); 211 - return -EINVAL; 209 + printk(KERN_INFO "go7007: probing for module i2c:%s failed\n", type); 210 + return -1; 212 211 } 213 212 214 213 /* ··· 238 249 } 239 250 if (go->i2c_adapter_online) { 240 251 for (i = 0; i < go->board_info->num_i2c_devs; ++i) 241 - init_i2c_module(&go->i2c_adapter, &go->board_info->i2c_devs[i]); 252 + init_i2c_module(&go->i2c_adapter, 253 + go->board_info->i2c_devs[i].type, 254 + go->board_info->i2c_devs[i].addr); 242 255 if (go->board_id == GO7007_BOARDID_ADLINK_MPG24) 243 256 i2c_clients_command(&go->i2c_adapter, 244 257 DECODER_SET_CHANNEL, &go->channel_number); ··· 571 580 struct go7007 *go; 572 581 int i; 573 582 574 - go = kzalloc(sizeof(struct go7007), GFP_KERNEL); 583 + go = kmalloc(sizeof(struct go7007), GFP_KERNEL); 575 584 if (go == NULL) 576 585 return NULL; 577 586 go->dev = dev;
+1 -1
drivers/staging/media/go7007/go7007-priv.h
··· 88 88 int audio_bclk_div; 89 89 int audio_main_div; 90 90 int num_i2c_devs; 91 - struct go_i2c { 91 + struct { 92 92 const char *type; 93 93 int id; 94 94 int addr;
+4 -1
drivers/staging/media/go7007/go7007-usb.c
··· 1110 1110 } else { 1111 1111 u16 channel; 1112 1112 1113 + /* set GPIO5 to be an output, currently low */ 1114 + go7007_write_addr(go, 0x3c82, 0x0000); 1115 + go7007_write_addr(go, 0x3c80, 0x00df); 1113 1116 /* read channel number from GPIO[1:0] */ 1114 1117 go7007_read_addr(go, 0x3c81, &channel); 1115 1118 channel &= 0x3; ··· 1245 1242 struct urb *vurb, *aurb; 1246 1243 int i; 1247 1244 1245 + go->status = STATUS_SHUTDOWN; 1248 1246 usb_kill_urb(usb->intr_urb); 1249 1247 1250 1248 /* Free USB-related structs */ ··· 1269 1265 kfree(go->hpi_context); 1270 1266 1271 1267 go7007_remove(go); 1272 - go->status = STATUS_SHUTDOWN; 1273 1268 } 1274 1269 1275 1270 static struct usb_driver go7007_usb_driver = {
+2 -5
drivers/staging/media/go7007/go7007-v4l2.c
··· 98 98 99 99 if (go->status != STATUS_ONLINE) 100 100 return -EBUSY; 101 - gofh = kzalloc(sizeof(struct go7007_file), GFP_KERNEL); 101 + gofh = kmalloc(sizeof(struct go7007_file), GFP_KERNEL); 102 102 if (gofh == NULL) 103 103 return -ENOMEM; 104 104 ++go->ref_count; ··· 953 953 } 954 954 mutex_unlock(&go->hw_lock); 955 955 mutex_unlock(&gofh->lock); 956 - call_all(&go->v4l2_dev, video, s_stream, 1); 957 956 958 957 return retval; 959 958 } ··· 968 969 mutex_lock(&gofh->lock); 969 970 go7007_streamoff(go); 970 971 mutex_unlock(&gofh->lock); 971 - call_all(&go->v4l2_dev, video, s_stream, 0); 972 972 973 973 return 0; 974 974 } ··· 1832 1834 mutex_unlock(&go->hw_lock); 1833 1835 if (go->video_dev) 1834 1836 video_unregister_device(go->video_dev); 1835 - if (go->status != STATUS_SHUTDOWN) 1836 - v4l2_device_unregister(&go->v4l2_dev); 1837 + v4l2_device_unregister(&go->v4l2_dev); 1837 1838 }
+148 -364
drivers/staging/media/go7007/wis-tw2804.c
··· 21 21 #include <linux/videodev2.h> 22 22 #include <linux/ioctl.h> 23 23 #include <linux/slab.h> 24 - #include <media/v4l2-subdev.h> 25 - #include <media/v4l2-device.h> 26 24 27 25 #include "wis-i2c.h" 28 26 29 27 struct wis_tw2804 { 30 - struct v4l2_subdev sd; 31 - u8 channel:2; 32 - u8 input:1; 33 - u8 update:1; 34 - u8 auto_gain:1; 35 - u8 ckil:1; 28 + int channel; 36 29 int norm; 37 - u8 brightness; 38 - u8 contrast; 39 - u8 saturation; 40 - u8 hue; 41 - u8 gain; 42 - u8 cr_gain; 43 - u8 r_balance; 44 - u8 b_balance; 30 + int brightness; 31 + int contrast; 32 + int saturation; 33 + int hue; 45 34 }; 46 35 47 36 static u8 global_registers[] = { ··· 41 52 0x3d, 0x80, 42 53 0x3e, 0x82, 43 54 0x3f, 0x82, 44 - 0x78, 0x0f, 45 55 0xff, 0xff, /* Terminator (reg 0xff does not exist) */ 46 56 }; 47 57 ··· 103 115 0xff, 0xff, /* Terminator (reg 0xff does not exist) */ 104 116 }; 105 117 106 - static s32 write_reg(struct i2c_client *client, u8 reg, u8 value, u8 channel) 118 + static int write_reg(struct i2c_client *client, u8 reg, u8 value, int channel) 107 119 { 108 120 return i2c_smbus_write_byte_data(client, reg | (channel << 6), value); 109 121 } 110 122 111 - static int write_regs(struct i2c_client *client, u8 *regs, u8 channel) 123 + static int write_regs(struct i2c_client *client, u8 *regs, int channel) 112 124 { 113 125 int i; 114 126 115 127 for (i = 0; regs[i] != 0xff; i += 2) 116 128 if (i2c_smbus_write_byte_data(client, 117 129 regs[i] | (channel << 6), regs[i + 1]) < 0) 118 - return -EINVAL; 130 + return -1; 119 131 return 0; 120 132 } 121 - 122 - static s32 read_reg(struct i2c_client *client, u8 reg, u8 channel) 123 - { 124 - return i2c_smbus_read_byte_data(client, (reg) | (channel << 6)); 125 - } 126 - 127 - static inline struct wis_tw2804 *to_state(struct v4l2_subdev *sd) 128 - { 129 - return container_of(sd, struct wis_tw2804, sd); 130 - } 131 - 132 - static int tw2804_log_status(struct v4l2_subdev *sd) 133 - { 134 - struct wis_tw2804 *state = to_state(sd); 135 - v4l2_info(sd, "Standard: %s\n", state->norm == V4L2_STD_NTSC ? "NTSC" : 136 - state->norm == V4L2_STD_PAL ? "PAL" : "unknown"); 137 - v4l2_info(sd, "Channel: %d\n", state->channel); 138 - v4l2_info(sd, "Input: %d\n", state->input); 139 - v4l2_info(sd, "Brightness: %d\n", state->brightness); 140 - v4l2_info(sd, "Contrast: %d\n", state->contrast); 141 - v4l2_info(sd, "Saturation: %d\n", state->saturation); 142 - v4l2_info(sd, "Hue: %d\n", state->hue); 143 - return 0; 144 - } 145 - 146 - static int tw2804_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *query) 147 - { 148 - static const u32 user_ctrls[] = { 149 - V4L2_CID_USER_CLASS, 150 - V4L2_CID_BRIGHTNESS, 151 - V4L2_CID_CONTRAST, 152 - V4L2_CID_SATURATION, 153 - V4L2_CID_HUE, 154 - V4L2_CID_AUTOGAIN, 155 - V4L2_CID_COLOR_KILLER, 156 - V4L2_CID_GAIN, 157 - V4L2_CID_CHROMA_GAIN, 158 - V4L2_CID_BLUE_BALANCE, 159 - V4L2_CID_RED_BALANCE, 160 - 0 161 - }; 162 - 163 - static const u32 *ctrl_classes[] = { 164 - user_ctrls, 165 - NULL 166 - }; 167 - 168 - query->id = v4l2_ctrl_next(ctrl_classes, query->id); 169 - 170 - switch (query->id) { 171 - case V4L2_CID_USER_CLASS: 172 - return v4l2_ctrl_query_fill(query, 0, 0, 0, 0); 173 - case V4L2_CID_BRIGHTNESS: 174 - return v4l2_ctrl_query_fill(query, 0, 255, 1, 128); 175 - case V4L2_CID_CONTRAST: 176 - return v4l2_ctrl_query_fill(query, 0, 255, 1, 128); 177 - case V4L2_CID_SATURATION: 178 - return v4l2_ctrl_query_fill(query, 0, 255, 1, 128); 179 - case V4L2_CID_HUE: 180 - return v4l2_ctrl_query_fill(query, 0, 255, 1, 128); 181 - case V4L2_CID_AUTOGAIN: 182 - return v4l2_ctrl_query_fill(query, 0, 1, 1, 0); 183 - case V4L2_CID_COLOR_KILLER: 184 - return v4l2_ctrl_query_fill(query, 0, 1, 1, 0); 185 - case V4L2_CID_GAIN: 186 - return v4l2_ctrl_query_fill(query, 0, 255, 1, 128); 187 - case V4L2_CID_CHROMA_GAIN: 188 - return v4l2_ctrl_query_fill(query, 0, 255, 1, 128); 189 - case V4L2_CID_BLUE_BALANCE: 190 - return v4l2_ctrl_query_fill(query, 0, 255, 1, 122); 191 - case V4L2_CID_RED_BALANCE: 192 - return v4l2_ctrl_query_fill(query, 0, 255, 1, 122); 193 - default: 194 - return -EINVAL; 195 - } 196 - } 197 - 198 - s32 get_ctrl_addr(int ctrl) 199 - { 200 - switch (ctrl) { 201 - case V4L2_CID_BRIGHTNESS: 202 - return 0x12; 203 - case V4L2_CID_CONTRAST: 204 - return 0x11; 205 - case V4L2_CID_SATURATION: 206 - return 0x10; 207 - case V4L2_CID_HUE: 208 - return 0x0f; 209 - case V4L2_CID_AUTOGAIN: 210 - return 0x02; 211 - case V4L2_CID_COLOR_KILLER: 212 - return 0x14; 213 - case V4L2_CID_GAIN: 214 - return 0x3c; 215 - case V4L2_CID_CHROMA_GAIN: 216 - return 0x3d; 217 - case V4L2_CID_RED_BALANCE: 218 - return 0x3f; 219 - case V4L2_CID_BLUE_BALANCE: 220 - return 0x3e; 221 - default: 222 - return -EINVAL; 223 - } 224 - } 225 - 226 - static int tw2804_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) 227 - { 228 - struct wis_tw2804 *state = to_state(sd); 229 - struct i2c_client *client = v4l2_get_subdevdata(sd); 230 - s32 addr = get_ctrl_addr(ctrl->id); 231 - s32 val = 0; 232 - 233 - if (addr == -EINVAL) 234 - return -EINVAL; 235 - 236 - if (state->update) { 237 - val = read_reg(client, addr, ctrl->id == V4L2_CID_GAIN || 238 - ctrl->id == V4L2_CID_CHROMA_GAIN || 239 - ctrl->id == V4L2_CID_RED_BALANCE || 240 - ctrl->id == V4L2_CID_BLUE_BALANCE ? 0 : state->channel); 241 - if (val < 0) 242 - return val; 243 - } 244 - 245 - switch (ctrl->id) { 246 - case V4L2_CID_BRIGHTNESS: 247 - if (state->update) 248 - state->brightness = val; 249 - ctrl->value = state->brightness; 250 - break; 251 - case V4L2_CID_CONTRAST: 252 - if (state->update) 253 - state->contrast = val; 254 - ctrl->value = state->contrast; 255 - break; 256 - case V4L2_CID_SATURATION: 257 - if (state->update) 258 - state->saturation = val; 259 - ctrl->value = state->saturation; 260 - break; 261 - case V4L2_CID_HUE: 262 - if (state->update) 263 - state->hue = val; 264 - ctrl->value = state->hue; 265 - break; 266 - case V4L2_CID_AUTOGAIN: 267 - if (state->update) 268 - state->auto_gain = val & (1<<7) ? 1 : 0; 269 - ctrl->value = state->auto_gain; 270 - break; 271 - case V4L2_CID_COLOR_KILLER: 272 - if (state->update) 273 - state->ckil = (val & 0x03) == 0x03 ? 1 : 0; 274 - ctrl->value = state->ckil; 275 - break; 276 - case V4L2_CID_GAIN: 277 - if (state->update) 278 - state->gain = val; 279 - ctrl->value = state->gain; 280 - break; 281 - case V4L2_CID_CHROMA_GAIN: 282 - if (state->update) 283 - state->cr_gain = val; 284 - ctrl->value = state->cr_gain; 285 - break; 286 - case V4L2_CID_RED_BALANCE: 287 - if (state->update) 288 - state->r_balance = val; 289 - ctrl->value = state->r_balance; 290 - break; 291 - case V4L2_CID_BLUE_BALANCE: 292 - if (state->update) 293 - state->b_balance = val; 294 - ctrl->value = state->b_balance; 295 - break; 296 - default: 297 - return -EINVAL; 298 - } 299 - 300 - state->update = 0; 301 - return 0; 302 - } 303 - 304 - static int tw2804_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) 305 - { 306 - struct wis_tw2804 *dec = to_state(sd); 307 - struct i2c_client *client = v4l2_get_subdevdata(sd); 308 - s32 reg = 0; 309 - s32 addr = get_ctrl_addr(ctrl->id); 310 - 311 - if (addr == -EINVAL) 312 - return -EINVAL; 313 - 314 - switch (ctrl->id) { 315 - case V4L2_CID_AUTOGAIN: 316 - reg = read_reg(client, addr, dec->channel); 317 - if (reg > 0) { 318 - if (ctrl->value == 0) 319 - ctrl->value = reg & ~(1<<7); 320 - else 321 - ctrl->value = reg | 1<<7; 322 - } else 323 - return reg; 324 - break; 325 - case V4L2_CID_COLOR_KILLER: 326 - reg = read_reg(client, addr, dec->channel); 327 - if (reg > 0) 328 - ctrl->value = (reg & ~(0x03)) | (ctrl->value == 0 ? 0x02 : 0x03); 329 - else 330 - return reg; 331 - break; 332 - default: 333 - break; 334 - } 335 - 336 - ctrl->value = ctrl->value > 255 ? 255 : (ctrl->value < 0 ? 0 : ctrl->value); 337 - reg = write_reg(client, addr, (u8)ctrl->value, ctrl->id == V4L2_CID_GAIN || 338 - ctrl->id == V4L2_CID_CHROMA_GAIN || 339 - ctrl->id == V4L2_CID_RED_BALANCE || 340 - ctrl->id == V4L2_CID_BLUE_BALANCE ? 0 : dec->channel); 341 - 342 - if (reg < 0) { 343 - v4l2_err(&dec->sd, "Can`t set_ctrl value:id=%d;value=%d\n", ctrl->id, ctrl->value); 344 - return reg; 345 - } 346 - 347 - dec->update = 1; 348 - return tw2804_g_ctrl(sd, ctrl); 349 - } 350 - 351 - static int tw2804_s_std(struct v4l2_subdev *sd, v4l2_std_id norm) 352 - { 353 - struct wis_tw2804 *dec = to_state(sd); 354 - struct i2c_client *client = v4l2_get_subdevdata(sd); 355 - 356 - u8 regs[] = { 357 - 0x01, norm&V4L2_STD_NTSC ? 0xc4 : 0x84, 358 - 0x09, norm&V4L2_STD_NTSC ? 0x07 : 0x04, 359 - 0x0a, norm&V4L2_STD_NTSC ? 0xf0 : 0x20, 360 - 0x0b, norm&V4L2_STD_NTSC ? 0x07 : 0x04, 361 - 0x0c, norm&V4L2_STD_NTSC ? 0xf0 : 0x20, 362 - 0x0d, norm&V4L2_STD_NTSC ? 0x40 : 0x4a, 363 - 0x16, norm&V4L2_STD_NTSC ? 0x00 : 0x40, 364 - 0x17, norm&V4L2_STD_NTSC ? 0x00 : 0x40, 365 - 0x20, norm&V4L2_STD_NTSC ? 0x07 : 0x0f, 366 - 0x21, norm&V4L2_STD_NTSC ? 0x07 : 0x0f, 367 - 0xff, 0xff, 368 - }; 369 - write_regs(client, regs, dec->channel); 370 - dec->norm = norm; 371 - return 0; 372 - } 373 - 374 - static const struct v4l2_subdev_core_ops tw2804_core_ops = { 375 - .log_status = tw2804_log_status, 376 - .g_ctrl = tw2804_g_ctrl, 377 - .s_ctrl = tw2804_s_ctrl, 378 - .queryctrl = tw2804_queryctrl, 379 - .s_std = tw2804_s_std, 380 - }; 381 - 382 - static int tw2804_s_video_routing(struct v4l2_subdev *sd, u32 input, u32 output, 383 - u32 config) 384 - { 385 - struct wis_tw2804 *dec = to_state(sd); 386 - struct i2c_client *client = v4l2_get_subdevdata(sd); 387 - s32 reg = 0; 388 - 389 - if (0 > input || input > 1) 390 - return -EINVAL; 391 - 392 - if (input == dec->input && !dec->update) 393 - return 0; 394 - 395 - reg = read_reg(client, 0x22, dec->channel); 396 - 397 - if (reg >= 0) { 398 - if (input == 0) 399 - reg &= ~(1<<2); 400 - else 401 - reg |= 1<<2; 402 - reg = write_reg(client, 0x22, (u8)reg, dec->channel); 403 - } 404 - 405 - if (reg >= 0) { 406 - dec->input = input; 407 - dec->update = 0; 408 - } else 409 - return reg; 410 - return 0; 411 - } 412 - 413 - static int tw2804_s_mbus_fmt(struct v4l2_subdev *sd, 414 - struct v4l2_mbus_framefmt *fmt) 415 - { 416 - /*TODO need select between 3fmt: 417 - * bt_656, 418 - * bt_601_8bit, 419 - * bt_656_dual, 420 - */ 421 - return 0; 422 - } 423 - 424 - int tw2804_s_stream(struct v4l2_subdev *sd, int enable) 425 - { 426 - struct wis_tw2804 *dec = to_state(sd); 427 - struct i2c_client *client = v4l2_get_subdevdata(sd); 428 - u32 reg = read_reg(client, 0x78, 0); 429 - 430 - if (enable == 1) 431 - write_reg(client, 0x78, reg & ~(1<<dec->channel), 0); 432 - else 433 - write_reg(client, 0x78, reg | (1<<dec->channel), 0); 434 - 435 - return 0; 436 - } 437 - 438 - static const struct v4l2_subdev_video_ops tw2804_video_ops = { 439 - .s_routing = tw2804_s_video_routing, 440 - .s_mbus_fmt = tw2804_s_mbus_fmt, 441 - .s_stream = tw2804_s_stream, 442 - }; 443 - 444 - static const struct v4l2_subdev_ops tw2804_ops = { 445 - .core = &tw2804_core_ops, 446 - .video = &tw2804_video_ops, 447 - }; 448 133 449 134 static int wis_tw2804_command(struct i2c_client *client, 450 135 unsigned int cmd, void *arg) 451 136 { 452 - struct v4l2_subdev *sd = i2c_get_clientdata(client); 453 - struct wis_tw2804 *dec = to_state(sd); 454 - int *input; 137 + struct wis_tw2804 *dec = i2c_get_clientdata(client); 455 138 456 139 if (cmd == DECODER_SET_CHANNEL) { 457 - input = arg; 140 + int *input = arg; 458 141 459 142 if (*input < 0 || *input > 3) { 460 143 printk(KERN_ERR "wis-tw2804: channel %d is not " ··· 154 495 "channel number is set\n", cmd); 155 496 return 0; 156 497 } 498 + 499 + switch (cmd) { 500 + case VIDIOC_S_STD: 501 + { 502 + v4l2_std_id *input = arg; 503 + u8 regs[] = { 504 + 0x01, *input & V4L2_STD_NTSC ? 0xc4 : 0x84, 505 + 0x09, *input & V4L2_STD_NTSC ? 0x07 : 0x04, 506 + 0x0a, *input & V4L2_STD_NTSC ? 0xf0 : 0x20, 507 + 0x0b, *input & V4L2_STD_NTSC ? 0x07 : 0x04, 508 + 0x0c, *input & V4L2_STD_NTSC ? 0xf0 : 0x20, 509 + 0x0d, *input & V4L2_STD_NTSC ? 0x40 : 0x4a, 510 + 0x16, *input & V4L2_STD_NTSC ? 0x00 : 0x40, 511 + 0x17, *input & V4L2_STD_NTSC ? 0x00 : 0x40, 512 + 0x20, *input & V4L2_STD_NTSC ? 0x07 : 0x0f, 513 + 0x21, *input & V4L2_STD_NTSC ? 0x07 : 0x0f, 514 + 0xff, 0xff, 515 + }; 516 + write_regs(client, regs, dec->channel); 517 + dec->norm = *input; 518 + break; 519 + } 520 + case VIDIOC_QUERYCTRL: 521 + { 522 + struct v4l2_queryctrl *ctrl = arg; 523 + 524 + switch (ctrl->id) { 525 + case V4L2_CID_BRIGHTNESS: 526 + ctrl->type = V4L2_CTRL_TYPE_INTEGER; 527 + strncpy(ctrl->name, "Brightness", sizeof(ctrl->name)); 528 + ctrl->minimum = 0; 529 + ctrl->maximum = 255; 530 + ctrl->step = 1; 531 + ctrl->default_value = 128; 532 + ctrl->flags = 0; 533 + break; 534 + case V4L2_CID_CONTRAST: 535 + ctrl->type = V4L2_CTRL_TYPE_INTEGER; 536 + strncpy(ctrl->name, "Contrast", sizeof(ctrl->name)); 537 + ctrl->minimum = 0; 538 + ctrl->maximum = 255; 539 + ctrl->step = 1; 540 + ctrl->default_value = 128; 541 + ctrl->flags = 0; 542 + break; 543 + case V4L2_CID_SATURATION: 544 + ctrl->type = V4L2_CTRL_TYPE_INTEGER; 545 + strncpy(ctrl->name, "Saturation", sizeof(ctrl->name)); 546 + ctrl->minimum = 0; 547 + ctrl->maximum = 255; 548 + ctrl->step = 1; 549 + ctrl->default_value = 128; 550 + ctrl->flags = 0; 551 + break; 552 + case V4L2_CID_HUE: 553 + ctrl->type = V4L2_CTRL_TYPE_INTEGER; 554 + strncpy(ctrl->name, "Hue", sizeof(ctrl->name)); 555 + ctrl->minimum = 0; 556 + ctrl->maximum = 255; 557 + ctrl->step = 1; 558 + ctrl->default_value = 128; 559 + ctrl->flags = 0; 560 + break; 561 + } 562 + break; 563 + } 564 + case VIDIOC_S_CTRL: 565 + { 566 + struct v4l2_control *ctrl = arg; 567 + 568 + switch (ctrl->id) { 569 + case V4L2_CID_BRIGHTNESS: 570 + if (ctrl->value > 255) 571 + dec->brightness = 255; 572 + else if (ctrl->value < 0) 573 + dec->brightness = 0; 574 + else 575 + dec->brightness = ctrl->value; 576 + write_reg(client, 0x12, dec->brightness, dec->channel); 577 + break; 578 + case V4L2_CID_CONTRAST: 579 + if (ctrl->value > 255) 580 + dec->contrast = 255; 581 + else if (ctrl->value < 0) 582 + dec->contrast = 0; 583 + else 584 + dec->contrast = ctrl->value; 585 + write_reg(client, 0x11, dec->contrast, dec->channel); 586 + break; 587 + case V4L2_CID_SATURATION: 588 + if (ctrl->value > 255) 589 + dec->saturation = 255; 590 + else if (ctrl->value < 0) 591 + dec->saturation = 0; 592 + else 593 + dec->saturation = ctrl->value; 594 + write_reg(client, 0x10, dec->saturation, dec->channel); 595 + break; 596 + case V4L2_CID_HUE: 597 + if (ctrl->value > 255) 598 + dec->hue = 255; 599 + else if (ctrl->value < 0) 600 + dec->hue = 0; 601 + else 602 + dec->hue = ctrl->value; 603 + write_reg(client, 0x0f, dec->hue, dec->channel); 604 + break; 605 + } 606 + break; 607 + } 608 + case VIDIOC_G_CTRL: 609 + { 610 + struct v4l2_control *ctrl = arg; 611 + 612 + switch (ctrl->id) { 613 + case V4L2_CID_BRIGHTNESS: 614 + ctrl->value = dec->brightness; 615 + break; 616 + case V4L2_CID_CONTRAST: 617 + ctrl->value = dec->contrast; 618 + break; 619 + case V4L2_CID_SATURATION: 620 + ctrl->value = dec->saturation; 621 + break; 622 + case V4L2_CID_HUE: 623 + ctrl->value = dec->hue; 624 + break; 625 + } 626 + break; 627 + } 628 + default: 629 + break; 630 + } 157 631 return 0; 158 632 } 159 633 ··· 295 503 { 296 504 struct i2c_adapter *adapter = client->adapter; 297 505 struct wis_tw2804 *dec; 298 - struct v4l2_subdev *sd; 299 506 300 507 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 301 508 return -ENODEV; 302 509 303 - dec = kzalloc(sizeof(struct wis_tw2804), GFP_KERNEL); 304 - 510 + dec = kmalloc(sizeof(struct wis_tw2804), GFP_KERNEL); 305 511 if (dec == NULL) 306 512 return -ENOMEM; 307 - sd = &dec->sd; 308 - dec->update = 1; 513 + 309 514 dec->channel = -1; 310 515 dec->norm = V4L2_STD_NTSC; 311 516 dec->brightness = 128; 312 517 dec->contrast = 128; 313 518 dec->saturation = 128; 314 519 dec->hue = 128; 315 - dec->gain = 128; 316 - dec->cr_gain = 128; 317 - dec->b_balance = 122; 318 - dec->r_balance = 122; 319 - v4l2_i2c_subdev_init(sd, client, &tw2804_ops); 520 + i2c_set_clientdata(client, dec); 320 521 321 522 printk(KERN_DEBUG "wis-tw2804: creating TW2804 at address %d on %s\n", 322 523 client->addr, adapter->name); ··· 319 534 320 535 static int wis_tw2804_remove(struct i2c_client *client) 321 536 { 322 - struct v4l2_subdev *sd = i2c_get_clientdata(client); 537 + struct wis_tw2804 *dec = i2c_get_clientdata(client); 323 538 324 - v4l2_device_unregister_subdev(sd); 325 - kfree(to_state(sd)); 539 + kfree(dec); 326 540 return 0; 327 541 } 328 542