diff options
author | Guennadi Liakhovetski <g.liakhovetski@gmx.de> | 2009-08-25 10:28:22 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-09-18 23:18:27 -0400 |
commit | 40e2e0927003424c25807b575dd40da2b8685857 (patch) | |
tree | 917ca8fd5f7598194d264ec92a08b312d4932b90 /drivers/media/video/mt9m111.c | |
parent | bc1937b41d8253e2b554da385023a92189d38917 (diff) |
V4L/DVB (12506): soc-camera: convert to platform device
Convert soc-camera core and all drivers to platform device API. We already
converted platforms to register a platform device for each soc-camera client,
now we remove the compatibility code and switch completely to the new scheme.
This is a preparatory step for the v4l2-subdev conversion.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/mt9m111.c')
-rw-r--r-- | drivers/media/video/mt9m111.c | 154 |
1 files changed, 78 insertions, 76 deletions
diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index fc5e2de03766..95c2f089605f 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c | |||
@@ -148,8 +148,6 @@ enum mt9m111_context { | |||
148 | }; | 148 | }; |
149 | 149 | ||
150 | struct mt9m111 { | 150 | struct mt9m111 { |
151 | struct i2c_client *client; | ||
152 | struct soc_camera_device icd; | ||
153 | int model; /* V4L2_IDENT_MT9M11x* codes from v4l2-chip-ident.h */ | 151 | int model; /* V4L2_IDENT_MT9M11x* codes from v4l2-chip-ident.h */ |
154 | enum mt9m111_context context; | 152 | enum mt9m111_context context; |
155 | struct v4l2_rect rect; | 153 | struct v4l2_rect rect; |
@@ -203,7 +201,7 @@ static int mt9m111_reg_write(struct i2c_client *client, const u16 reg, | |||
203 | 201 | ||
204 | ret = reg_page_map_set(client, reg); | 202 | ret = reg_page_map_set(client, reg); |
205 | if (!ret) | 203 | if (!ret) |
206 | ret = i2c_smbus_write_word_data(client, (reg & 0xff), | 204 | ret = i2c_smbus_write_word_data(client, reg & 0xff, |
207 | swab16(data)); | 205 | swab16(data)); |
208 | dev_dbg(&client->dev, "write reg.%03x = %04x -> %d\n", reg, data, ret); | 206 | dev_dbg(&client->dev, "write reg.%03x = %04x -> %d\n", reg, data, ret); |
209 | return ret; | 207 | return ret; |
@@ -232,7 +230,7 @@ static int mt9m111_reg_clear(struct i2c_client *client, const u16 reg, | |||
232 | static int mt9m111_set_context(struct soc_camera_device *icd, | 230 | static int mt9m111_set_context(struct soc_camera_device *icd, |
233 | enum mt9m111_context ctxt) | 231 | enum mt9m111_context ctxt) |
234 | { | 232 | { |
235 | struct i2c_client *client = to_i2c_client(icd->control); | 233 | struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); |
236 | int valB = MT9M111_CTXT_CTRL_RESTART | MT9M111_CTXT_CTRL_DEFECTCOR_B | 234 | int valB = MT9M111_CTXT_CTRL_RESTART | MT9M111_CTXT_CTRL_DEFECTCOR_B |
237 | | MT9M111_CTXT_CTRL_RESIZE_B | MT9M111_CTXT_CTRL_CTRL2_B | 235 | | MT9M111_CTXT_CTRL_RESIZE_B | MT9M111_CTXT_CTRL_CTRL2_B |
238 | | MT9M111_CTXT_CTRL_GAMMA_B | MT9M111_CTXT_CTRL_READ_MODE_B | 236 | | MT9M111_CTXT_CTRL_GAMMA_B | MT9M111_CTXT_CTRL_READ_MODE_B |
@@ -249,8 +247,8 @@ static int mt9m111_set_context(struct soc_camera_device *icd, | |||
249 | static int mt9m111_setup_rect(struct soc_camera_device *icd, | 247 | static int mt9m111_setup_rect(struct soc_camera_device *icd, |
250 | struct v4l2_rect *rect) | 248 | struct v4l2_rect *rect) |
251 | { | 249 | { |
252 | struct i2c_client *client = to_i2c_client(icd->control); | 250 | struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); |
253 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); | 251 | struct mt9m111 *mt9m111 = i2c_get_clientdata(client); |
254 | int ret, is_raw_format; | 252 | int ret, is_raw_format; |
255 | int width = rect->width; | 253 | int width = rect->width; |
256 | int height = rect->height; | 254 | int height = rect->height; |
@@ -294,7 +292,7 @@ static int mt9m111_setup_rect(struct soc_camera_device *icd, | |||
294 | 292 | ||
295 | static int mt9m111_setup_pixfmt(struct soc_camera_device *icd, u16 outfmt) | 293 | static int mt9m111_setup_pixfmt(struct soc_camera_device *icd, u16 outfmt) |
296 | { | 294 | { |
297 | struct i2c_client *client = to_i2c_client(icd->control); | 295 | struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); |
298 | int ret; | 296 | int ret; |
299 | 297 | ||
300 | ret = reg_write(OUTPUT_FORMAT_CTRL2_A, outfmt); | 298 | ret = reg_write(OUTPUT_FORMAT_CTRL2_A, outfmt); |
@@ -315,7 +313,8 @@ static int mt9m111_setfmt_bayer10(struct soc_camera_device *icd) | |||
315 | 313 | ||
316 | static int mt9m111_setfmt_rgb565(struct soc_camera_device *icd) | 314 | static int mt9m111_setfmt_rgb565(struct soc_camera_device *icd) |
317 | { | 315 | { |
318 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); | 316 | struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); |
317 | struct mt9m111 *mt9m111 = i2c_get_clientdata(client); | ||
319 | int val = 0; | 318 | int val = 0; |
320 | 319 | ||
321 | if (mt9m111->swap_rgb_red_blue) | 320 | if (mt9m111->swap_rgb_red_blue) |
@@ -329,7 +328,8 @@ static int mt9m111_setfmt_rgb565(struct soc_camera_device *icd) | |||
329 | 328 | ||
330 | static int mt9m111_setfmt_rgb555(struct soc_camera_device *icd) | 329 | static int mt9m111_setfmt_rgb555(struct soc_camera_device *icd) |
331 | { | 330 | { |
332 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); | 331 | struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); |
332 | struct mt9m111 *mt9m111 = i2c_get_clientdata(client); | ||
333 | int val = 0; | 333 | int val = 0; |
334 | 334 | ||
335 | if (mt9m111->swap_rgb_red_blue) | 335 | if (mt9m111->swap_rgb_red_blue) |
@@ -343,7 +343,8 @@ static int mt9m111_setfmt_rgb555(struct soc_camera_device *icd) | |||
343 | 343 | ||
344 | static int mt9m111_setfmt_yuv(struct soc_camera_device *icd) | 344 | static int mt9m111_setfmt_yuv(struct soc_camera_device *icd) |
345 | { | 345 | { |
346 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); | 346 | struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); |
347 | struct mt9m111 *mt9m111 = i2c_get_clientdata(client); | ||
347 | int val = 0; | 348 | int val = 0; |
348 | 349 | ||
349 | if (mt9m111->swap_yuv_cb_cr) | 350 | if (mt9m111->swap_yuv_cb_cr) |
@@ -356,9 +357,9 @@ static int mt9m111_setfmt_yuv(struct soc_camera_device *icd) | |||
356 | 357 | ||
357 | static int mt9m111_enable(struct soc_camera_device *icd) | 358 | static int mt9m111_enable(struct soc_camera_device *icd) |
358 | { | 359 | { |
359 | struct i2c_client *client = to_i2c_client(icd->control); | 360 | struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); |
360 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); | 361 | struct soc_camera_link *icl = to_soc_camera_link(icd); |
361 | struct soc_camera_link *icl = client->dev.platform_data; | 362 | struct mt9m111 *mt9m111 = i2c_get_clientdata(client); |
362 | int ret; | 363 | int ret; |
363 | 364 | ||
364 | if (icl->power) { | 365 | if (icl->power) { |
@@ -378,9 +379,9 @@ static int mt9m111_enable(struct soc_camera_device *icd) | |||
378 | 379 | ||
379 | static int mt9m111_disable(struct soc_camera_device *icd) | 380 | static int mt9m111_disable(struct soc_camera_device *icd) |
380 | { | 381 | { |
381 | struct i2c_client *client = to_i2c_client(icd->control); | 382 | struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); |
382 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); | 383 | struct soc_camera_link *icl = to_soc_camera_link(icd); |
383 | struct soc_camera_link *icl = client->dev.platform_data; | 384 | struct mt9m111 *mt9m111 = i2c_get_clientdata(client); |
384 | int ret; | 385 | int ret; |
385 | 386 | ||
386 | ret = reg_clear(RESET, MT9M111_RESET_CHIP_ENABLE); | 387 | ret = reg_clear(RESET, MT9M111_RESET_CHIP_ENABLE); |
@@ -395,8 +396,8 @@ static int mt9m111_disable(struct soc_camera_device *icd) | |||
395 | 396 | ||
396 | static int mt9m111_reset(struct soc_camera_device *icd) | 397 | static int mt9m111_reset(struct soc_camera_device *icd) |
397 | { | 398 | { |
398 | struct i2c_client *client = to_i2c_client(icd->control); | 399 | struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); |
399 | struct soc_camera_link *icl = client->dev.platform_data; | 400 | struct soc_camera_link *icl = to_soc_camera_link(icd); |
400 | int ret; | 401 | int ret; |
401 | 402 | ||
402 | ret = reg_set(RESET, MT9M111_RESET_RESET_MODE); | 403 | ret = reg_set(RESET, MT9M111_RESET_RESET_MODE); |
@@ -424,8 +425,7 @@ static int mt9m111_stop_capture(struct soc_camera_device *icd) | |||
424 | 425 | ||
425 | static unsigned long mt9m111_query_bus_param(struct soc_camera_device *icd) | 426 | static unsigned long mt9m111_query_bus_param(struct soc_camera_device *icd) |
426 | { | 427 | { |
427 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); | 428 | struct soc_camera_link *icl = to_soc_camera_link(icd); |
428 | struct soc_camera_link *icl = mt9m111->client->dev.platform_data; | ||
429 | unsigned long flags = SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING | | 429 | unsigned long flags = SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING | |
430 | SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_HIGH | | 430 | SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_HIGH | |
431 | SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8; | 431 | SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8; |
@@ -441,7 +441,8 @@ static int mt9m111_set_bus_param(struct soc_camera_device *icd, unsigned long f) | |||
441 | static int mt9m111_set_crop(struct soc_camera_device *icd, | 441 | static int mt9m111_set_crop(struct soc_camera_device *icd, |
442 | struct v4l2_rect *rect) | 442 | struct v4l2_rect *rect) |
443 | { | 443 | { |
444 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); | 444 | struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); |
445 | struct mt9m111 *mt9m111 = i2c_get_clientdata(client); | ||
445 | int ret; | 446 | int ret; |
446 | 447 | ||
447 | dev_dbg(&icd->dev, "%s left=%d, top=%d, width=%d, height=%d\n", | 448 | dev_dbg(&icd->dev, "%s left=%d, top=%d, width=%d, height=%d\n", |
@@ -456,7 +457,8 @@ static int mt9m111_set_crop(struct soc_camera_device *icd, | |||
456 | 457 | ||
457 | static int mt9m111_set_pixfmt(struct soc_camera_device *icd, u32 pixfmt) | 458 | static int mt9m111_set_pixfmt(struct soc_camera_device *icd, u32 pixfmt) |
458 | { | 459 | { |
459 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); | 460 | struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); |
461 | struct mt9m111 *mt9m111 = i2c_get_clientdata(client); | ||
460 | int ret; | 462 | int ret; |
461 | 463 | ||
462 | switch (pixfmt) { | 464 | switch (pixfmt) { |
@@ -506,7 +508,8 @@ static int mt9m111_set_pixfmt(struct soc_camera_device *icd, u32 pixfmt) | |||
506 | static int mt9m111_set_fmt(struct soc_camera_device *icd, | 508 | static int mt9m111_set_fmt(struct soc_camera_device *icd, |
507 | struct v4l2_format *f) | 509 | struct v4l2_format *f) |
508 | { | 510 | { |
509 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); | 511 | struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); |
512 | struct mt9m111 *mt9m111 = i2c_get_clientdata(client); | ||
510 | struct v4l2_pix_format *pix = &f->fmt.pix; | 513 | struct v4l2_pix_format *pix = &f->fmt.pix; |
511 | struct v4l2_rect rect = { | 514 | struct v4l2_rect rect = { |
512 | .left = mt9m111->rect.left, | 515 | .left = mt9m111->rect.left, |
@@ -544,12 +547,13 @@ static int mt9m111_try_fmt(struct soc_camera_device *icd, | |||
544 | static int mt9m111_get_chip_id(struct soc_camera_device *icd, | 547 | static int mt9m111_get_chip_id(struct soc_camera_device *icd, |
545 | struct v4l2_dbg_chip_ident *id) | 548 | struct v4l2_dbg_chip_ident *id) |
546 | { | 549 | { |
547 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); | 550 | struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); |
551 | struct mt9m111 *mt9m111 = i2c_get_clientdata(client); | ||
548 | 552 | ||
549 | if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR) | 553 | if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR) |
550 | return -EINVAL; | 554 | return -EINVAL; |
551 | 555 | ||
552 | if (id->match.addr != mt9m111->client->addr) | 556 | if (id->match.addr != client->addr) |
553 | return -ENODEV; | 557 | return -ENODEV; |
554 | 558 | ||
555 | id->ident = mt9m111->model; | 559 | id->ident = mt9m111->model; |
@@ -562,8 +566,8 @@ static int mt9m111_get_chip_id(struct soc_camera_device *icd, | |||
562 | static int mt9m111_get_register(struct soc_camera_device *icd, | 566 | static int mt9m111_get_register(struct soc_camera_device *icd, |
563 | struct v4l2_dbg_register *reg) | 567 | struct v4l2_dbg_register *reg) |
564 | { | 568 | { |
569 | struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); | ||
565 | int val; | 570 | int val; |
566 | struct i2c_client *client = to_i2c_client(icd->control); | ||
567 | 571 | ||
568 | if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0x2ff) | 572 | if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0x2ff) |
569 | return -EINVAL; | 573 | return -EINVAL; |
@@ -583,7 +587,7 @@ static int mt9m111_get_register(struct soc_camera_device *icd, | |||
583 | static int mt9m111_set_register(struct soc_camera_device *icd, | 587 | static int mt9m111_set_register(struct soc_camera_device *icd, |
584 | struct v4l2_dbg_register *reg) | 588 | struct v4l2_dbg_register *reg) |
585 | { | 589 | { |
586 | struct i2c_client *client = to_i2c_client(icd->control); | 590 | struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); |
587 | 591 | ||
588 | if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0x2ff) | 592 | if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0x2ff) |
589 | return -EINVAL; | 593 | return -EINVAL; |
@@ -635,8 +639,6 @@ static const struct v4l2_queryctrl mt9m111_controls[] = { | |||
635 | } | 639 | } |
636 | }; | 640 | }; |
637 | 641 | ||
638 | static int mt9m111_video_probe(struct soc_camera_device *); | ||
639 | static void mt9m111_video_remove(struct soc_camera_device *); | ||
640 | static int mt9m111_get_control(struct soc_camera_device *, | 642 | static int mt9m111_get_control(struct soc_camera_device *, |
641 | struct v4l2_control *); | 643 | struct v4l2_control *); |
642 | static int mt9m111_set_control(struct soc_camera_device *, | 644 | static int mt9m111_set_control(struct soc_camera_device *, |
@@ -647,8 +649,6 @@ static int mt9m111_release(struct soc_camera_device *icd); | |||
647 | 649 | ||
648 | static struct soc_camera_ops mt9m111_ops = { | 650 | static struct soc_camera_ops mt9m111_ops = { |
649 | .owner = THIS_MODULE, | 651 | .owner = THIS_MODULE, |
650 | .probe = mt9m111_video_probe, | ||
651 | .remove = mt9m111_video_remove, | ||
652 | .init = mt9m111_init, | 652 | .init = mt9m111_init, |
653 | .resume = mt9m111_resume, | 653 | .resume = mt9m111_resume, |
654 | .release = mt9m111_release, | 654 | .release = mt9m111_release, |
@@ -672,8 +672,8 @@ static struct soc_camera_ops mt9m111_ops = { | |||
672 | 672 | ||
673 | static int mt9m111_set_flip(struct soc_camera_device *icd, int flip, int mask) | 673 | static int mt9m111_set_flip(struct soc_camera_device *icd, int flip, int mask) |
674 | { | 674 | { |
675 | struct i2c_client *client = to_i2c_client(icd->control); | 675 | struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); |
676 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); | 676 | struct mt9m111 *mt9m111 = i2c_get_clientdata(client); |
677 | int ret; | 677 | int ret; |
678 | 678 | ||
679 | if (mt9m111->context == HIGHPOWER) { | 679 | if (mt9m111->context == HIGHPOWER) { |
@@ -693,7 +693,7 @@ static int mt9m111_set_flip(struct soc_camera_device *icd, int flip, int mask) | |||
693 | 693 | ||
694 | static int mt9m111_get_global_gain(struct soc_camera_device *icd) | 694 | static int mt9m111_get_global_gain(struct soc_camera_device *icd) |
695 | { | 695 | { |
696 | struct i2c_client *client = to_i2c_client(icd->control); | 696 | struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); |
697 | int data; | 697 | int data; |
698 | 698 | ||
699 | data = reg_read(GLOBAL_GAIN); | 699 | data = reg_read(GLOBAL_GAIN); |
@@ -705,7 +705,7 @@ static int mt9m111_get_global_gain(struct soc_camera_device *icd) | |||
705 | 705 | ||
706 | static int mt9m111_set_global_gain(struct soc_camera_device *icd, int gain) | 706 | static int mt9m111_set_global_gain(struct soc_camera_device *icd, int gain) |
707 | { | 707 | { |
708 | struct i2c_client *client = to_i2c_client(icd->control); | 708 | struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); |
709 | u16 val; | 709 | u16 val; |
710 | 710 | ||
711 | if (gain > 63 * 2 * 2) | 711 | if (gain > 63 * 2 * 2) |
@@ -724,8 +724,8 @@ static int mt9m111_set_global_gain(struct soc_camera_device *icd, int gain) | |||
724 | 724 | ||
725 | static int mt9m111_set_autoexposure(struct soc_camera_device *icd, int on) | 725 | static int mt9m111_set_autoexposure(struct soc_camera_device *icd, int on) |
726 | { | 726 | { |
727 | struct i2c_client *client = to_i2c_client(icd->control); | 727 | struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); |
728 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); | 728 | struct mt9m111 *mt9m111 = i2c_get_clientdata(client); |
729 | int ret; | 729 | int ret; |
730 | 730 | ||
731 | if (on) | 731 | if (on) |
@@ -741,8 +741,8 @@ static int mt9m111_set_autoexposure(struct soc_camera_device *icd, int on) | |||
741 | 741 | ||
742 | static int mt9m111_set_autowhitebalance(struct soc_camera_device *icd, int on) | 742 | static int mt9m111_set_autowhitebalance(struct soc_camera_device *icd, int on) |
743 | { | 743 | { |
744 | struct i2c_client *client = to_i2c_client(icd->control); | 744 | struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); |
745 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); | 745 | struct mt9m111 *mt9m111 = i2c_get_clientdata(client); |
746 | int ret; | 746 | int ret; |
747 | 747 | ||
748 | if (on) | 748 | if (on) |
@@ -759,8 +759,8 @@ static int mt9m111_set_autowhitebalance(struct soc_camera_device *icd, int on) | |||
759 | static int mt9m111_get_control(struct soc_camera_device *icd, | 759 | static int mt9m111_get_control(struct soc_camera_device *icd, |
760 | struct v4l2_control *ctrl) | 760 | struct v4l2_control *ctrl) |
761 | { | 761 | { |
762 | struct i2c_client *client = to_i2c_client(icd->control); | 762 | struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); |
763 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); | 763 | struct mt9m111 *mt9m111 = i2c_get_clientdata(client); |
764 | int data; | 764 | int data; |
765 | 765 | ||
766 | switch (ctrl->id) { | 766 | switch (ctrl->id) { |
@@ -803,7 +803,8 @@ static int mt9m111_get_control(struct soc_camera_device *icd, | |||
803 | static int mt9m111_set_control(struct soc_camera_device *icd, | 803 | static int mt9m111_set_control(struct soc_camera_device *icd, |
804 | struct v4l2_control *ctrl) | 804 | struct v4l2_control *ctrl) |
805 | { | 805 | { |
806 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); | 806 | struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); |
807 | struct mt9m111 *mt9m111 = i2c_get_clientdata(client); | ||
807 | const struct v4l2_queryctrl *qctrl; | 808 | const struct v4l2_queryctrl *qctrl; |
808 | int ret; | 809 | int ret; |
809 | 810 | ||
@@ -841,7 +842,8 @@ static int mt9m111_set_control(struct soc_camera_device *icd, | |||
841 | 842 | ||
842 | static int mt9m111_restore_state(struct soc_camera_device *icd) | 843 | static int mt9m111_restore_state(struct soc_camera_device *icd) |
843 | { | 844 | { |
844 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); | 845 | struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); |
846 | struct mt9m111 *mt9m111 = i2c_get_clientdata(client); | ||
845 | 847 | ||
846 | mt9m111_set_context(icd, mt9m111->context); | 848 | mt9m111_set_context(icd, mt9m111->context); |
847 | mt9m111_set_pixfmt(icd, mt9m111->pixfmt); | 849 | mt9m111_set_pixfmt(icd, mt9m111->pixfmt); |
@@ -856,7 +858,8 @@ static int mt9m111_restore_state(struct soc_camera_device *icd) | |||
856 | 858 | ||
857 | static int mt9m111_resume(struct soc_camera_device *icd) | 859 | static int mt9m111_resume(struct soc_camera_device *icd) |
858 | { | 860 | { |
859 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); | 861 | struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); |
862 | struct mt9m111 *mt9m111 = i2c_get_clientdata(client); | ||
860 | int ret = 0; | 863 | int ret = 0; |
861 | 864 | ||
862 | if (mt9m111->powered) { | 865 | if (mt9m111->powered) { |
@@ -871,7 +874,8 @@ static int mt9m111_resume(struct soc_camera_device *icd) | |||
871 | 874 | ||
872 | static int mt9m111_init(struct soc_camera_device *icd) | 875 | static int mt9m111_init(struct soc_camera_device *icd) |
873 | { | 876 | { |
874 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); | 877 | struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); |
878 | struct mt9m111 *mt9m111 = i2c_get_clientdata(client); | ||
875 | int ret; | 879 | int ret; |
876 | 880 | ||
877 | mt9m111->context = HIGHPOWER; | 881 | mt9m111->context = HIGHPOWER; |
@@ -902,10 +906,10 @@ static int mt9m111_release(struct soc_camera_device *icd) | |||
902 | * Interface active, can use i2c. If it fails, it can indeed mean, that | 906 | * Interface active, can use i2c. If it fails, it can indeed mean, that |
903 | * this wasn't our capture interface, so, we wait for the right one | 907 | * this wasn't our capture interface, so, we wait for the right one |
904 | */ | 908 | */ |
905 | static int mt9m111_video_probe(struct soc_camera_device *icd) | 909 | static int mt9m111_video_probe(struct soc_camera_device *icd, |
910 | struct i2c_client *client) | ||
906 | { | 911 | { |
907 | struct i2c_client *client = to_i2c_client(icd->control); | 912 | struct mt9m111 *mt9m111 = i2c_get_clientdata(client); |
908 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); | ||
909 | s32 data; | 913 | s32 data; |
910 | int ret; | 914 | int ret; |
911 | 915 | ||
@@ -917,6 +921,11 @@ static int mt9m111_video_probe(struct soc_camera_device *icd) | |||
917 | to_soc_camera_host(icd->dev.parent)->nr != icd->iface) | 921 | to_soc_camera_host(icd->dev.parent)->nr != icd->iface) |
918 | return -ENODEV; | 922 | return -ENODEV; |
919 | 923 | ||
924 | /* Switch master clock on */ | ||
925 | ret = soc_camera_video_start(icd, &client->dev); | ||
926 | if (ret) | ||
927 | goto evstart; | ||
928 | |||
920 | ret = mt9m111_enable(icd); | 929 | ret = mt9m111_enable(icd); |
921 | if (ret) | 930 | if (ret) |
922 | goto ei2c; | 931 | goto ei2c; |
@@ -945,40 +954,33 @@ static int mt9m111_video_probe(struct soc_camera_device *icd) | |||
945 | 954 | ||
946 | dev_info(&icd->dev, "Detected a MT9M11x chip ID %x\n", data); | 955 | dev_info(&icd->dev, "Detected a MT9M11x chip ID %x\n", data); |
947 | 956 | ||
948 | ret = soc_camera_video_start(icd); | ||
949 | if (ret) | ||
950 | goto eisis; | ||
951 | |||
952 | mt9m111->autoexposure = 1; | 957 | mt9m111->autoexposure = 1; |
953 | mt9m111->autowhitebalance = 1; | 958 | mt9m111->autowhitebalance = 1; |
954 | 959 | ||
955 | mt9m111->swap_rgb_even_odd = 1; | 960 | mt9m111->swap_rgb_even_odd = 1; |
956 | mt9m111->swap_rgb_red_blue = 1; | 961 | mt9m111->swap_rgb_red_blue = 1; |
957 | 962 | ||
958 | return 0; | ||
959 | eisis: | ||
960 | ei2c: | 963 | ei2c: |
964 | soc_camera_video_stop(icd); | ||
965 | evstart: | ||
961 | return ret; | 966 | return ret; |
962 | } | 967 | } |
963 | 968 | ||
964 | static void mt9m111_video_remove(struct soc_camera_device *icd) | ||
965 | { | ||
966 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); | ||
967 | |||
968 | dev_dbg(&icd->dev, "Video %x removed: %p, %p\n", mt9m111->client->addr, | ||
969 | mt9m111->icd.dev.parent, mt9m111->icd.vdev); | ||
970 | soc_camera_video_stop(&mt9m111->icd); | ||
971 | } | ||
972 | |||
973 | static int mt9m111_probe(struct i2c_client *client, | 969 | static int mt9m111_probe(struct i2c_client *client, |
974 | const struct i2c_device_id *did) | 970 | const struct i2c_device_id *did) |
975 | { | 971 | { |
976 | struct mt9m111 *mt9m111; | 972 | struct mt9m111 *mt9m111; |
977 | struct soc_camera_device *icd; | 973 | struct soc_camera_device *icd = client->dev.platform_data; |
978 | struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); | 974 | struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); |
979 | struct soc_camera_link *icl = client->dev.platform_data; | 975 | struct soc_camera_link *icl; |
980 | int ret; | 976 | int ret; |
981 | 977 | ||
978 | if (!icd) { | ||
979 | dev_err(&client->dev, "MT9M11x: missing soc-camera data!\n"); | ||
980 | return -EINVAL; | ||
981 | } | ||
982 | |||
983 | icl = to_soc_camera_link(icd); | ||
982 | if (!icl) { | 984 | if (!icl) { |
983 | dev_err(&client->dev, "MT9M11x driver needs platform data\n"); | 985 | dev_err(&client->dev, "MT9M11x driver needs platform data\n"); |
984 | return -EINVAL; | 986 | return -EINVAL; |
@@ -994,13 +996,10 @@ static int mt9m111_probe(struct i2c_client *client, | |||
994 | if (!mt9m111) | 996 | if (!mt9m111) |
995 | return -ENOMEM; | 997 | return -ENOMEM; |
996 | 998 | ||
997 | mt9m111->client = client; | ||
998 | i2c_set_clientdata(client, mt9m111); | 999 | i2c_set_clientdata(client, mt9m111); |
999 | 1000 | ||
1000 | /* Second stage probe - when a capture adapter is there */ | 1001 | /* Second stage probe - when a capture adapter is there */ |
1001 | icd = &mt9m111->icd; | ||
1002 | icd->ops = &mt9m111_ops; | 1002 | icd->ops = &mt9m111_ops; |
1003 | icd->control = &client->dev; | ||
1004 | icd->x_min = MT9M111_MIN_DARK_COLS; | 1003 | icd->x_min = MT9M111_MIN_DARK_COLS; |
1005 | icd->y_min = MT9M111_MIN_DARK_ROWS; | 1004 | icd->y_min = MT9M111_MIN_DARK_ROWS; |
1006 | icd->x_current = icd->x_min; | 1005 | icd->x_current = icd->x_min; |
@@ -1010,22 +1009,25 @@ static int mt9m111_probe(struct i2c_client *client, | |||
1010 | icd->height_min = MT9M111_MIN_DARK_COLS; | 1009 | icd->height_min = MT9M111_MIN_DARK_COLS; |
1011 | icd->height_max = MT9M111_MAX_HEIGHT; | 1010 | icd->height_max = MT9M111_MAX_HEIGHT; |
1012 | icd->y_skip_top = 0; | 1011 | icd->y_skip_top = 0; |
1013 | icd->iface = icl->bus_id; | ||
1014 | 1012 | ||
1015 | ret = soc_camera_device_register(icd); | 1013 | ret = mt9m111_video_probe(icd, client); |
1016 | if (ret) | 1014 | if (ret) { |
1017 | goto eisdr; | 1015 | icd->ops = NULL; |
1018 | return 0; | 1016 | i2c_set_clientdata(client, NULL); |
1017 | kfree(mt9m111); | ||
1018 | } | ||
1019 | 1019 | ||
1020 | eisdr: | ||
1021 | kfree(mt9m111); | ||
1022 | return ret; | 1020 | return ret; |
1023 | } | 1021 | } |
1024 | 1022 | ||
1025 | static int mt9m111_remove(struct i2c_client *client) | 1023 | static int mt9m111_remove(struct i2c_client *client) |
1026 | { | 1024 | { |
1027 | struct mt9m111 *mt9m111 = i2c_get_clientdata(client); | 1025 | struct mt9m111 *mt9m111 = i2c_get_clientdata(client); |
1028 | soc_camera_device_unregister(&mt9m111->icd); | 1026 | struct soc_camera_device *icd = client->dev.platform_data; |
1027 | |||
1028 | icd->ops = NULL; | ||
1029 | i2c_set_clientdata(client, NULL); | ||
1030 | client->driver = NULL; | ||
1029 | kfree(mt9m111); | 1031 | kfree(mt9m111); |
1030 | 1032 | ||
1031 | return 0; | 1033 | return 0; |