diff options
Diffstat (limited to 'drivers/media/i2c')
-rw-r--r-- | drivers/media/i2c/Kconfig | 1 | ||||
-rw-r--r-- | drivers/media/i2c/adv7180.c | 1 | ||||
-rw-r--r-- | drivers/media/i2c/adv7604.c | 5 | ||||
-rw-r--r-- | drivers/media/i2c/ir-kbd-i2c.c | 95 | ||||
-rw-r--r-- | drivers/media/i2c/mt9v032.c | 170 | ||||
-rw-r--r-- | drivers/media/i2c/noon010pc30.c | 1 | ||||
-rw-r--r-- | drivers/media/i2c/s5k4ecgx.c | 1 | ||||
-rw-r--r-- | drivers/media/i2c/s5k5baf.c | 2 | ||||
-rw-r--r-- | drivers/media/i2c/s5k6a3.c | 1 | ||||
-rw-r--r-- | drivers/media/i2c/smiapp/smiapp-core.c | 17 | ||||
-rw-r--r-- | drivers/media/i2c/soc_camera/mt9m001.c | 6 | ||||
-rw-r--r-- | drivers/media/i2c/soc_camera/mt9m111.c | 12 | ||||
-rw-r--r-- | drivers/media/i2c/soc_camera/mt9t031.c | 6 | ||||
-rw-r--r-- | drivers/media/i2c/soc_camera/mt9v022.c | 4 | ||||
-rw-r--r-- | drivers/media/i2c/tvp5150.c | 35 |
15 files changed, 195 insertions, 162 deletions
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig index 441053be7f5..f40b4cf6107 100644 --- a/drivers/media/i2c/Kconfig +++ b/drivers/media/i2c/Kconfig @@ -551,6 +551,7 @@ config VIDEO_MT9V032 tristate "Micron MT9V032 sensor support" depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API depends on MEDIA_CAMERA_SUPPORT + select REGMAP_I2C ---help--- This is a Video4Linux2 sensor-level driver for the Micron MT9V032 752x480 CMOS sensor. diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c index ac1cdbe251a..821178dcb08 100644 --- a/drivers/media/i2c/adv7180.c +++ b/drivers/media/i2c/adv7180.c @@ -663,7 +663,6 @@ static int adv7180_remove(struct i2c_client *client) if (state->irq > 0) free_irq(client->irq, state); - v4l2_device_unregister_subdev(sd); adv7180_exit_controls(state); mutex_destroy(&state->mutex); return 0; diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c index 1778d320272..d4fa213ba74 100644 --- a/drivers/media/i2c/adv7604.c +++ b/drivers/media/i2c/adv7604.c @@ -2588,8 +2588,11 @@ static const struct adv7604_reg_seq adv7604_recommended_settings_hdmi[] = { }; static const struct adv7604_reg_seq adv7611_recommended_settings_hdmi[] = { + /* ADV7611 Register Settings Recommendations Rev 1.5, May 2014 */ { ADV7604_REG(ADV7604_PAGE_CP, 0x6c), 0x00 }, - { ADV7604_REG(ADV7604_PAGE_HDMI, 0x6f), 0x0c }, + { ADV7604_REG(ADV7604_PAGE_HDMI, 0x9b), 0x03 }, + { ADV7604_REG(ADV7604_PAGE_HDMI, 0x6f), 0x08 }, + { ADV7604_REG(ADV7604_PAGE_HDMI, 0x85), 0x1f }, { ADV7604_REG(ADV7604_PAGE_HDMI, 0x87), 0x70 }, { ADV7604_REG(ADV7604_PAGE_HDMI, 0x57), 0xda }, { ADV7604_REG(ADV7604_PAGE_HDMI, 0x58), 0x01 }, diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c index c8fe1358ec9..8311f1a9a38 100644 --- a/drivers/media/i2c/ir-kbd-i2c.c +++ b/drivers/media/i2c/ir-kbd-i2c.c @@ -62,8 +62,8 @@ module_param(debug, int, 0644); /* debug level (0,1,2) */ /* ----------------------------------------------------------------------- */ -static int get_key_haup_common(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw, - int size, int offset) +static int get_key_haup_common(struct IR_i2c *ir, enum rc_type *protocol, + u32 *scancode, u8 *ptoggle, int size, int offset) { unsigned char buf[6]; int start, range, toggle, dev, code, ircode; @@ -86,19 +86,10 @@ static int get_key_haup_common(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw, if (!start) /* no key pressed */ return 0; - /* - * Hauppauge remotes (black/silver) always use - * specific device ids. If we do not filter the - * device ids then messages destined for devices - * such as TVs (id=0) will get through causing - * mis-fired events. - * - * We also filter out invalid key presses which - * produce annoying debug log entries. - */ - ircode= (start << 12) | (toggle << 11) | (dev << 6) | code; - if ((ircode & 0x1fff)==0x1fff) - /* invalid key press */ + + /* filter out invalid key presses */ + ircode = (start << 12) | (toggle << 11) | (dev << 6) | code; + if ((ircode & 0x1fff) == 0x1fff) return 0; if (!range) @@ -107,18 +98,20 @@ static int get_key_haup_common(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw, dprintk(1,"ir hauppauge (rc5): s%d r%d t%d dev=%d code=%d\n", start, range, toggle, dev, code); - /* return key */ - *ir_key = (dev << 8) | code; - *ir_raw = ircode; + *protocol = RC_TYPE_RC5; + *scancode = RC_SCANCODE_RC5(dev, code); + *ptoggle = toggle; return 1; } -static int get_key_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) +static int get_key_haup(struct IR_i2c *ir, enum rc_type *protocol, + u32 *scancode, u8 *toggle) { - return get_key_haup_common (ir, ir_key, ir_raw, 3, 0); + return get_key_haup_common (ir, protocol, scancode, toggle, 3, 0); } -static int get_key_haup_xvr(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) +static int get_key_haup_xvr(struct IR_i2c *ir, enum rc_type *protocol, + u32 *scancode, u8 *toggle) { int ret; unsigned char buf[1] = { 0 }; @@ -133,10 +126,11 @@ static int get_key_haup_xvr(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) if (ret != 1) return (ret < 0) ? ret : -EINVAL; - return get_key_haup_common (ir, ir_key, ir_raw, 6, 3); + return get_key_haup_common(ir, protocol, scancode, toggle, 6, 3); } -static int get_key_pixelview(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) +static int get_key_pixelview(struct IR_i2c *ir, enum rc_type *protocol, + u32 *scancode, u8 *toggle) { unsigned char b; @@ -145,12 +139,15 @@ static int get_key_pixelview(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) dprintk(1,"read error\n"); return -EIO; } - *ir_key = b; - *ir_raw = b; + + *protocol = RC_TYPE_OTHER; + *scancode = b; + *toggle = 0; return 1; } -static int get_key_fusionhdtv(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) +static int get_key_fusionhdtv(struct IR_i2c *ir, enum rc_type *protocol, + u32 *scancode, u8 *toggle) { unsigned char buf[4]; @@ -168,13 +165,14 @@ static int get_key_fusionhdtv(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) if(buf[0] != 0x1 || buf[1] != 0xfe) return 0; - *ir_key = buf[2]; - *ir_raw = (buf[2] << 8) | buf[3]; - + *protocol = RC_TYPE_UNKNOWN; + *scancode = buf[2]; + *toggle = 0; return 1; } -static int get_key_knc1(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) +static int get_key_knc1(struct IR_i2c *ir, enum rc_type *protocol, + u32 *scancode, u8 *toggle) { unsigned char b; @@ -197,13 +195,14 @@ static int get_key_knc1(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) /* keep old data */ return 1; - *ir_key = b; - *ir_raw = b; + *protocol = RC_TYPE_UNKNOWN; + *scancode = b; + *toggle = 0; return 1; } -static int get_key_avermedia_cardbus(struct IR_i2c *ir, - u32 *ir_key, u32 *ir_raw) +static int get_key_avermedia_cardbus(struct IR_i2c *ir, enum rc_type *protocol, + u32 *scancode, u8 *toggle) { unsigned char subaddr, key, keygroup; struct i2c_msg msg[] = { { .addr = ir->c->addr, .flags = 0, @@ -237,12 +236,11 @@ static int get_key_avermedia_cardbus(struct IR_i2c *ir, } key |= (keygroup & 1) << 6; - *ir_key = key; - *ir_raw = key; - if (!strcmp(ir->ir_codes, RC_MAP_AVERMEDIA_M733A_RM_K6)) { - *ir_key |= keygroup << 8; - *ir_raw |= keygroup << 8; - } + *protocol = RC_TYPE_UNKNOWN; + *scancode = key; + if (ir->c->addr == 0x41) /* AVerMedia EM78P153 */ + *scancode |= keygroup << 8; + *toggle = 0; return 1; } @@ -250,19 +248,22 @@ static int get_key_avermedia_cardbus(struct IR_i2c *ir, static int ir_key_poll(struct IR_i2c *ir) { - static u32 ir_key, ir_raw; + enum rc_type protocol; + u32 scancode; + u8 toggle; int rc; dprintk(3, "%s\n", __func__); - rc = ir->get_key(ir, &ir_key, &ir_raw); + rc = ir->get_key(ir, &protocol, &scancode, &toggle); if (rc < 0) { dprintk(2,"error\n"); return rc; } if (rc) { - dprintk(1, "%s: keycode = 0x%04x\n", __func__, ir_key); - rc_keydown(ir->rc, ir_key, 0); + dprintk(1, "%s: proto = 0x%04x, scancode = 0x%08x\n", + __func__, protocol, scancode); + rc_keydown(ir->rc, protocol, scancode, toggle); } return 0; } @@ -327,7 +328,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) case 0x6b: name = "FusionHDTV"; ir->get_key = get_key_fusionhdtv; - rc_type = RC_BIT_RC5; + rc_type = RC_BIT_UNKNOWN; ir_codes = RC_MAP_FUSIONHDTV_MCE; break; case 0x40: @@ -431,8 +432,8 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) * Initialize the other fields of rc_dev */ rc->map_name = ir->ir_codes; - rc_set_allowed_protocols(rc, rc_type); - rc_set_enabled_protocols(rc, rc_type); + rc->allowed_protocols = rc_type; + rc->enabled_protocols = rc_type; if (!rc->driver_name) rc->driver_name = MODULE_NAME; diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c index 40172b8d8ea..d044bce312e 100644 --- a/drivers/media/i2c/mt9v032.c +++ b/drivers/media/i2c/mt9v032.c @@ -1,5 +1,5 @@ /* - * Driver for MT9V032 CMOS Image Sensor from Micron + * Driver for MT9V022, MT9V024, MT9V032, and MT9V034 CMOS Image Sensors * * Copyright (C) 2010, Laurent Pinchart <laurent.pinchart@ideasonboard.com> * @@ -17,6 +17,7 @@ #include <linux/i2c.h> #include <linux/log2.h> #include <linux/mutex.h> +#include <linux/regmap.h> #include <linux/slab.h> #include <linux/videodev2.h> #include <linux/v4l2-mediabus.h> @@ -87,6 +88,7 @@ #define MT9V032_READ_MODE_COLUMN_FLIP (1 << 5) #define MT9V032_READ_MODE_DARK_COLUMNS (1 << 6) #define MT9V032_READ_MODE_DARK_ROWS (1 << 7) +#define MT9V032_READ_MODE_RESERVED 0x0300 #define MT9V032_PIXEL_OPERATION_MODE 0x0f #define MT9V034_PIXEL_OPERATION_MODE_HDR (1 << 0) #define MT9V034_PIXEL_OPERATION_MODE_COLOR (1 << 1) @@ -133,8 +135,12 @@ #define MT9V032_THERMAL_INFO 0xc1 enum mt9v032_model { - MT9V032_MODEL_V032_COLOR, - MT9V032_MODEL_V032_MONO, + MT9V032_MODEL_V022_COLOR, /* MT9V022IX7ATC */ + MT9V032_MODEL_V022_MONO, /* MT9V022IX7ATM */ + MT9V032_MODEL_V024_COLOR, /* MT9V024IA7XTC */ + MT9V032_MODEL_V024_MONO, /* MT9V024IA7XTM */ + MT9V032_MODEL_V032_COLOR, /* MT9V032C12STM */ + MT9V032_MODEL_V032_MONO, /* MT9V032C12STC */ MT9V032_MODEL_V034_COLOR, MT9V032_MODEL_V034_MONO, }; @@ -160,14 +166,14 @@ struct mt9v032_model_info { }; static const struct mt9v032_model_version mt9v032_versions[] = { - { MT9V032_CHIP_ID_REV1, "MT9V032 rev1/2" }, - { MT9V032_CHIP_ID_REV3, "MT9V032 rev3" }, - { MT9V034_CHIP_ID_REV1, "MT9V034 rev1" }, + { MT9V032_CHIP_ID_REV1, "MT9V022/MT9V032 rev1/2" }, + { MT9V032_CHIP_ID_REV3, "MT9V022/MT9V032 rev3" }, + { MT9V034_CHIP_ID_REV1, "MT9V024/MT9V034 rev1" }, }; static const struct mt9v032_model_data mt9v032_model_data[] = { { - /* MT9V032 revisions 1/2/3 */ + /* MT9V022, MT9V032 revisions 1/2/3 */ .min_row_time = 660, .min_hblank = MT9V032_HORIZONTAL_BLANKING_MIN, .min_vblank = MT9V032_VERTICAL_BLANKING_MIN, @@ -176,7 +182,7 @@ static const struct mt9v032_model_data mt9v032_model_data[] = { .max_shutter = MT9V032_TOTAL_SHUTTER_WIDTH_MAX, .pclk_reg = MT9V032_PIXEL_CLOCK, }, { - /* MT9V034 */ + /* MT9V024, MT9V034 */ .min_row_time = 690, .min_hblank = MT9V034_HORIZONTAL_BLANKING_MIN, .min_vblank = MT9V034_VERTICAL_BLANKING_MIN, @@ -188,6 +194,22 @@ static const struct mt9v032_model_data mt9v032_model_data[] = { }; static const struct mt9v032_model_info mt9v032_models[] = { + [MT9V032_MODEL_V022_COLOR] = { + .data = &mt9v032_model_data[0], + .color = true, + }, + [MT9V032_MODEL_V022_MONO] = { + .data = &mt9v032_model_data[0], + .color = false, + }, + [MT9V032_MODEL_V024_COLOR] = { + .data = &mt9v032_model_data[1], + .color = true, + }, + [MT9V032_MODEL_V024_MONO] = { + .data = &mt9v032_model_data[1], + .color = false, + }, [MT9V032_MODEL_V032_COLOR] = { .data = &mt9v032_model_data[0], .color = true, @@ -224,6 +246,7 @@ struct mt9v032 { struct mutex power_lock; int power_count; + struct regmap *regmap; struct clk *clk; struct mt9v032_platform_data *pdata; @@ -231,7 +254,6 @@ struct mt9v032 { const struct mt9v032_model_version *version; u32 sysclk; - u16 chip_control; u16 aec_agc; u16 hblank; struct { @@ -245,40 +267,10 @@ static struct mt9v032 *to_mt9v032(struct v4l2_subdev *sd) return container_of(sd, struct mt9v032, subdev); } -static int mt9v032_read(struct i2c_client *client, const u8 reg) -{ - s32 data = i2c_smbus_read_word_swapped(client, reg); - dev_dbg(&client->dev, "%s: read 0x%04x from 0x%02x\n", __func__, - data, reg); - return data; -} - -static int mt9v032_write(struct i2c_client *client, const u8 reg, - const u16 data) -{ - dev_dbg(&client->dev, "%s: writing 0x%04x to 0x%02x\n", __func__, - data, reg); - return i2c_smbus_write_word_swapped(client, reg, data); -} - -static int mt9v032_set_chip_control(struct mt9v032 *mt9v032, u16 clear, u16 set) -{ - struct i2c_client *client = v4l2_get_subdevdata(&mt9v032->subdev); - u16 value = (mt9v032->chip_control & ~clear) | set; - int ret; - - ret = mt9v032_write(client, MT9V032_CHIP_CONTROL, value); - if (ret < 0) - return ret; - - mt9v032->chip_control = value; - return 0; -} - static int mt9v032_update_aec_agc(struct mt9v032 *mt9v032, u16 which, int enable) { - struct i2c_client *client = v4l2_get_subdevdata(&mt9v032->subdev); + struct regmap *map = mt9v032->regmap; u16 value = mt9v032->aec_agc; int ret; @@ -287,7 +279,7 @@ mt9v032_update_aec_agc(struct mt9v032 *mt9v032, u16 which, int enable) else value &= ~which; - ret = mt9v032_write(client, MT9V032_AEC_AGC_ENABLE, value); + ret = regmap_write(map, MT9V032_AEC_AGC_ENABLE, value); if (ret < 0) return ret; @@ -298,23 +290,23 @@ mt9v032_update_aec_agc(struct mt9v032 *mt9v032, u16 which, int enable) static int mt9v032_update_hblank(struct mt9v032 *mt9v032) { - struct i2c_client *client = v4l2_get_subdevdata(&mt9v032->subdev); struct v4l2_rect *crop = &mt9v032->crop; unsigned int min_hblank = mt9v032->model->data->min_hblank; unsigned int hblank; if (mt9v032->version->version == MT9V034_CHIP_ID_REV1) min_hblank += (mt9v032->hratio - 1) * 10; - min_hblank = max_t(unsigned int, (int)mt9v032->model->data->min_row_time - crop->width, - (int)min_hblank); + min_hblank = max_t(int, mt9v032->model->data->min_row_time - crop->width, + min_hblank); hblank = max_t(unsigned int, mt9v032->hblank, min_hblank); - return mt9v032_write(client, MT9V032_HORIZONTAL_BLANKING, hblank); + return regmap_write(mt9v032->regmap, MT9V032_HORIZONTAL_BLANKING, + hblank); } static int mt9v032_power_on(struct mt9v032 *mt9v032) { - struct i2c_client *client = v4l2_get_subdevdata(&mt9v032->subdev); + struct regmap *map = mt9v032->regmap; int ret; ret = clk_set_rate(mt9v032->clk, mt9v032->sysclk); @@ -328,15 +320,15 @@ static int mt9v032_power_on(struct mt9v032 *mt9v032) udelay(1); /* Reset the chip and stop data read out */ - ret = mt9v032_write(client, MT9V032_RESET, 1); + ret = regmap_write(map, MT9V032_RESET, 1); if (ret < 0) return ret; - ret = mt9v032_write(client, MT9V032_RESET, 0); + ret = regmap_write(map, MT9V032_RESET, 0); if (ret < 0) return ret; - return mt9v032_write(client, MT9V032_CHIP_CONTROL, 0); + return regmap_write(map, MT9V032_CHIP_CONTROL, 0); } static void mt9v032_power_off(struct mt9v032 *mt9v032) @@ -346,7 +338,7 @@ static void mt9v032_power_off(struct mt9v032 *mt9v032) static int __mt9v032_set_power(struct mt9v032 *mt9v032, bool on) { - struct i2c_client *client = v4l2_get_subdevdata(&mt9v032->subdev); + struct regmap *map = mt9v032->regmap; int ret; if (!on) { @@ -360,14 +352,14 @@ static int __mt9v032_set_power(struct mt9v032 *mt9v032, bool on) /* Configure the pixel clock polarity */ if (mt9v032->pdata && mt9v032->pdata->clk_pol) { - ret = mt9v032_write(client, mt9v032->model->data->pclk_reg, + ret = regmap_write(map, mt9v032->model->data->pclk_reg, MT9V032_PIXEL_CLOCK_INV_PXL_CLK); if (ret < 0) return ret; } /* Disable the noise correction algorithm and restore the controls. */ - ret = mt9v032_write(client, MT9V032_ROW_NOISE_CORR_CONTROL, 0); + ret = regmap_write(map, MT9V032_ROW_NOISE_CORR_CONTROL, 0); if (ret < 0) return ret; @@ -411,38 +403,39 @@ static int mt9v032_s_stream(struct v4l2_subdev *subdev, int enable) const u16 mode = MT9V032_CHIP_CONTROL_MASTER_MODE | MT9V032_CHIP_CONTROL_DOUT_ENABLE | MT9V032_CHIP_CONTROL_SEQUENTIAL; - struct i2c_client *client = v4l2_get_subdevdata(subdev); struct mt9v032 *mt9v032 = to_mt9v032(subdev); struct v4l2_rect *crop = &mt9v032->crop; + struct regmap *map = mt9v032->regmap; unsigned int hbin; unsigned int vbin; int ret; if (!enable) - return mt9v032_set_chip_control(mt9v032, mode, 0); + return regmap_update_bits(map, MT9V032_CHIP_CONTROL, mode, 0); /* Configure the window size and row/column bin */ hbin = fls(mt9v032->hratio) - 1; vbin = fls(mt9v032->vratio) - 1; - ret = mt9v032_write(client, MT9V032_READ_MODE, - hbin << MT9V032_READ_MODE_COLUMN_BIN_SHIFT | - vbin << MT9V032_READ_MODE_ROW_BIN_SHIFT); + ret = regmap_update_bits(map, MT9V032_READ_MODE, + ~MT9V032_READ_MODE_RESERVED, + hbin << MT9V032_READ_MODE_COLUMN_BIN_SHIFT | + vbin << MT9V032_READ_MODE_ROW_BIN_SHIFT); if (ret < 0) return ret; - ret = mt9v032_write(client, MT9V032_COLUMN_START, crop->left); + ret = regmap_write(map, MT9V032_COLUMN_START, crop->left); if (ret < 0) return ret; - ret = mt9v032_write(client, MT9V032_ROW_START, crop->top); + ret = regmap_write(map, MT9V032_ROW_START, crop->top); if (ret < 0) return ret; - ret = mt9v032_write(client, MT9V032_WINDOW_WIDTH, crop->width); + ret = regmap_write(map, MT9V032_WINDOW_WIDTH, crop->width); if (ret < 0) return ret; - ret = mt9v032_write(client, MT9V032_WINDOW_HEIGHT, crop->height); + ret = regmap_write(map, MT9V032_WINDOW_HEIGHT, crop->height); if (ret < 0) return ret; @@ -451,7 +444,7 @@ static int mt9v032_s_stream(struct v4l2_subdev *subdev, int enable) return ret; /* Switch to master "normal" mode */ - return mt9v032_set_chip_control(mt9v032, 0, mode); + return regmap_update_bits(map, MT9V032_CHIP_CONTROL, mode, mode); } static int mt9v032_enum_mbus_code(struct v4l2_subdev *subdev, @@ -633,7 +626,7 @@ static int mt9v032_s_ctrl(struct v4l2_ctrl *ctrl) { struct mt9v032 *mt9v032 = container_of(ctrl->handler, struct mt9v032, ctrls); - struct i2c_client *client = v4l2_get_subdevdata(&mt9v032->subdev); + struct regmap *map = mt9v032->regmap; u32 freq; u16 data; @@ -643,23 +636,23 @@ static int mt9v032_s_ctrl(struct v4l2_ctrl *ctrl) ctrl->val); case V4L2_CID_GAIN: - return mt9v032_write(client, MT9V032_ANALOG_GAIN, ctrl->val); + return regmap_write(map, MT9V032_ANALOG_GAIN, ctrl->val); case V4L2_CID_EXPOSURE_AUTO: return mt9v032_update_aec_agc(mt9v032, MT9V032_AEC_ENABLE, !ctrl->val); case V4L2_CID_EXPOSURE: - return mt9v032_write(client, MT9V032_TOTAL_SHUTTER_WIDTH, - ctrl->val); + return regmap_write(map, MT9V032_TOTAL_SHUTTER_WIDTH, + ctrl->val); case V4L2_CID_HBLANK: mt9v032->hblank = ctrl->val; return mt9v032_update_hblank(mt9v032); case V4L2_CID_VBLANK: - return mt9v032_write(client, MT9V032_VERTICAL_BLANKING, - ctrl->val); + return regmap_write(map, MT9V032_VERTICAL_BLANKING, + ctrl->val); case V4L2_CID_PIXEL_RATE: case V4L2_CID_LINK_FREQ: @@ -667,7 +660,7 @@ static int mt9v032_s_ctrl(struct v4l2_ctrl *ctrl) break; freq = mt9v032->pdata->link_freqs[mt9v032->link_freq->val]; - mt9v032->pixel_rate->val64 = freq; + *mt9v032->pixel_rate->p_new.p_s64 = freq; mt9v032->sysclk = freq; break; @@ -696,7 +689,7 @@ static int mt9v032_s_ctrl(struct v4l2_ctrl *ctrl) | MT9V032_TEST_PATTERN_FLIP; break; } - return mt9v032_write(client, MT9V032_TEST_PATTERN, data); + return regmap_write(map, MT9V032_TEST_PATTERN, data); } return 0; @@ -764,7 +757,7 @@ static int mt9v032_registered(struct v4l2_subdev *subdev) struct i2c_client *client = v4l2_get_subdevdata(subdev); struct mt9v032 *mt9v032 = to_mt9v032(subdev); unsigned int i; - s32 version; + u32 version; int ret; dev_info(&client->dev, "Probing MT9V032 at address 0x%02x\n", @@ -777,10 +770,10 @@ static int mt9v032_registered(struct v4l2_subdev *subdev) } /* Read and check the sensor version */ - version = mt9v032_read(client, MT9V032_CHIP_VERSION); - if (version < 0) { + ret = regmap_read(mt9v032->regmap, MT9V032_CHIP_VERSION, &version); + if (ret < 0) { dev_err(&client->dev, "Failed reading chip version\n"); - return version; + return ret; } for (i = 0; i < ARRAY_SIZE(mt9v032_versions); ++i) { @@ -867,6 +860,13 @@ static const struct v4l2_subdev_internal_ops mt9v032_subdev_internal_ops = { .close = mt9v032_close, }; +static const struct regmap_config mt9v032_regmap_config = { + .reg_bits = 8, + .val_bits = 16, + .max_register = 0xff, + .cache_type = REGCACHE_RBTREE, +}; + /* ----------------------------------------------------------------------------- * Driver initialization and probing */ @@ -890,6 +890,10 @@ static int mt9v032_probe(struct i2c_client *client, if (!mt9v032) return -ENOMEM; + mt9v032->regmap = devm_regmap_init_i2c(client, &mt9v032_regmap_config); + if (IS_ERR(mt9v032->regmap)) + return PTR_ERR(mt9v032->regmap); + mt9v032->clk = devm_clk_get(&client->dev, NULL); if (IS_ERR(mt9v032->clk)) return PTR_ERR(mt9v032->clk); @@ -931,7 +935,7 @@ static int mt9v032_probe(struct i2c_client *client, mt9v032->pixel_rate = v4l2_ctrl_new_std(&mt9v032->ctrls, &mt9v032_ctrl_ops, - V4L2_CID_PIXEL_RATE, 0, 0, 1, 0); + V4L2_CID_PIXEL_RATE, 1, INT_MAX, 1, 1); if (pdata && pdata->link_freqs) { unsigned int def = 0; @@ -984,10 +988,19 @@ static int mt9v032_probe(struct i2c_client *client, mt9v032->pad.flags = MEDIA_PAD_FL_SOURCE; ret = media_entity_init(&mt9v032->subdev.entity, 1, &mt9v032->pad, 0); + if (ret < 0) + goto err; + mt9v032->subdev.dev = &client->dev; + ret = v4l2_async_register_subdev(&mt9v032->subdev); if (ret < 0) - v4l2_ctrl_handler_free(&mt9v032->ctrls); + goto err; + return 0; + +err: + media_entity_cleanup(&mt9v032->subdev.entity); + v4l2_ctrl_handler_free(&mt9v032->ctrls); return ret; } @@ -996,6 +1009,7 @@ static int mt9v032_remove(struct i2c_client *client) struct v4l2_subdev *subdev = i2c_get_clientdata(client); struct mt9v032 *mt9v032 = to_mt9v032(subdev); + v4l2_async_unregister_subdev(subdev); v4l2_ctrl_handler_free(&mt9v032->ctrls); v4l2_device_unregister_subdev(subdev); media_entity_cleanup(&subdev->entity); @@ -1004,6 +1018,10 @@ static int mt9v032_remove(struct i2c_client *client) } static const struct i2c_device_id mt9v032_id[] = { + { "mt9v022", (kernel_ulong_t)&mt9v032_models[MT9V032_MODEL_V022_COLOR] }, + { "mt9v022m", (kernel_ulong_t)&mt9v032_models[MT9V032_MODEL_V022_MONO] }, + { "mt9v024", (kernel_ulong_t)&mt9v032_models[MT9V032_MODEL_V024_COLOR] }, + { "mt9v024m", (kernel_ulong_t)&mt9v032_models[MT9V032_MODEL_V024_MONO] }, { "mt9v032", (kernel_ulong_t)&mt9v032_models[MT9V032_MODEL_V032_COLOR] }, { "mt9v032m", (kernel_ulong_t)&mt9v032_models[MT9V032_MODEL_V032_MONO] }, { "mt9v034", (kernel_ulong_t)&mt9v032_models[MT9V032_MODEL_V034_COLOR] }, diff --git a/drivers/media/i2c/noon010pc30.c b/drivers/media/i2c/noon010pc30.c index 271d0b7967a..7eae48766e2 100644 --- a/drivers/media/i2c/noon010pc30.c +++ b/drivers/media/i2c/noon010pc30.c @@ -554,6 +554,7 @@ static int noon010_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, nf = noon010_try_fmt(sd, &fmt->format); noon010_try_frame_size(&fmt->format, &size); fmt->format.colorspace = V4L2_COLORSPACE_JPEG; + fmt->format.field = V4L2_FIELD_NONE; if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { if (fh) { diff --git a/drivers/media/i2c/s5k4ecgx.c b/drivers/media/i2c/s5k4ecgx.c index 2750de63427..1fcc76fd1bb 100644 --- a/drivers/media/i2c/s5k4ecgx.c +++ b/drivers/media/i2c/s5k4ecgx.c @@ -594,6 +594,7 @@ static int s5k4ecgx_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, pf = s5k4ecgx_try_fmt(sd, &fmt->format); s5k4ecgx_try_frame_size(&fmt->format, &fsize); fmt->format.colorspace = V4L2_COLORSPACE_JPEG; + fmt->format.field = V4L2_FIELD_NONE; if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { if (fh) { diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c index 2d768ef67cc..564f05f2c9e 100644 --- a/drivers/media/i2c/s5k5baf.c +++ b/drivers/media/i2c/s5k5baf.c @@ -1313,6 +1313,8 @@ static int s5k5baf_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, const struct s5k5baf_pixfmt *pixfmt; int ret = 0; + mf->field = V4L2_FIELD_NONE; + if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { *v4l2_subdev_get_try_format(fh, fmt->pad) = *mf; return 0; diff --git a/drivers/media/i2c/s5k6a3.c b/drivers/media/i2c/s5k6a3.c index 7bc2271ca00..c11a40850ed 100644 --- a/drivers/media/i2c/s5k6a3.c +++ b/drivers/media/i2c/s5k6a3.c @@ -115,6 +115,7 @@ static void s5k6a3_try_format(struct v4l2_mbus_framefmt *mf) fmt = find_sensor_format(mf); mf->code = fmt->code; + mf->field = V4L2_FIELD_NONE; v4l_bound_align_image(&mf->width, S5K6A3_SENSOR_MIN_WIDTH, S5K6A3_SENSOR_MAX_WIDTH, 0, &mf->height, S5K6A3_SENSOR_MIN_HEIGHT, diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c index 06fb03291d5..1eaf975d361 100644 --- a/drivers/media/i2c/smiapp/smiapp-core.c +++ b/drivers/media/i2c/smiapp/smiapp-core.c @@ -297,8 +297,8 @@ static int smiapp_pll_update(struct smiapp_sensor *sensor) if (rval < 0) return rval; - sensor->pixel_rate_parray->cur.val64 = pll->vt_pix_clk_freq_hz; - sensor->pixel_rate_csi->cur.val64 = pll->pixel_rate_csi; + *sensor->pixel_rate_parray->p_cur.p_s64 = pll->vt_pix_clk_freq_hz; + *sensor->pixel_rate_csi->p_cur.p_s64 = pll->pixel_rate_csi; return 0; } @@ -533,7 +533,7 @@ static int smiapp_init_controls(struct smiapp_sensor *sensor) sensor->pixel_rate_parray = v4l2_ctrl_new_std( &sensor->pixel_array->ctrl_handler, &smiapp_ctrl_ops, - V4L2_CID_PIXEL_RATE, 0, 0, 1, 0); + V4L2_CID_PIXEL_RATE, 1, INT_MAX, 1, 1); if (sensor->pixel_array->ctrl_handler.error) { dev_err(&client->dev, @@ -562,7 +562,7 @@ static int smiapp_init_controls(struct smiapp_sensor *sensor) sensor->pixel_rate_csi = v4l2_ctrl_new_std( &sensor->src->ctrl_handler, &smiapp_ctrl_ops, - V4L2_CID_PIXEL_RATE, 0, 0, 1, 0); + V4L2_CID_PIXEL_RATE, 1, INT_MAX, 1, 1); if (sensor->src->ctrl_handler.error) { dev_err(&client->dev, @@ -1554,6 +1554,7 @@ static int __smiapp_get_format(struct v4l2_subdev *subdev, fmt->format.code = __smiapp_get_mbus_code(subdev, fmt->pad); fmt->format.width = r->width; fmt->format.height = r->height; + fmt->format.field = V4L2_FIELD_NONE; } return 0; @@ -1687,6 +1688,7 @@ static int smiapp_set_format(struct v4l2_subdev *subdev, fmt->format.code = __smiapp_get_mbus_code(subdev, fmt->pad); fmt->format.width &= ~1; fmt->format.height &= ~1; + fmt->format.field = V4L2_FIELD_NONE; fmt->format.width = clamp(fmt->format.width, @@ -2544,9 +2546,9 @@ static int smiapp_registered(struct v4l2_subdev *subdev) } snprintf(this->sd.name, - sizeof(this->sd.name), "%s %d-%4.4x %s", - sensor->minfo.name, i2c_adapter_id(client->adapter), - client->addr, _this->name); + sizeof(this->sd.name), "%s %s %d-%4.4x", + sensor->minfo.name, _this->name, + i2c_adapter_id(client->adapter), client->addr); this->sink_fmt.width = sensor->limits[SMIAPP_LIMIT_X_ADDR_MAX] + 1; @@ -2674,6 +2676,7 @@ static int smiapp_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) try_fmt->width = sensor->limits[SMIAPP_LIMIT_X_ADDR_MAX] + 1; try_fmt->height = sensor->limits[SMIAPP_LIMIT_Y_ADDR_MAX] + 1; try_fmt->code = mbus_code; + try_fmt->field = V4L2_FIELD_NONE; try_crop->top = 0; try_crop->left = 0; diff --git a/drivers/media/i2c/soc_camera/mt9m001.c b/drivers/media/i2c/soc_camera/mt9m001.c index df97033fa6e..dbd8c142d6e 100644 --- a/drivers/media/i2c/soc_camera/mt9m001.c +++ b/drivers/media/i2c/soc_camera/mt9m001.c @@ -403,7 +403,7 @@ static int mt9m001_s_ctrl(struct v4l2_ctrl *ctrl) if (ctrl->val <= ctrl->default_value) { /* Pack it into 0..1 step 0.125, register values 0..8 */ unsigned long range = ctrl->default_value - ctrl->minimum; - data = ((ctrl->val - ctrl->minimum) * 8 + range / 2) / range; + data = ((ctrl->val - (s32)ctrl->minimum) * 8 + range / 2) / range; dev_dbg(&client->dev, "Setting gain %d\n", data); data = reg_write(client, MT9M001_GLOBAL_GAIN, data); @@ -413,7 +413,7 @@ static int mt9m001_s_ctrl(struct v4l2_ctrl *ctrl) /* Pack it into 1.125..15 variable step, register values 9..67 */ /* We assume qctrl->maximum - qctrl->default_value - 1 > 0 */ unsigned long range = ctrl->maximum - ctrl->default_value - 1; - unsigned long gain = ((ctrl->val - ctrl->default_value - 1) * + unsigned long gain = ((ctrl->val - (s32)ctrl->default_value - 1) * 111 + range / 2) / range + 9; if (gain <= 32) @@ -434,7 +434,7 @@ static int mt9m001_s_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_EXPOSURE_AUTO: if (ctrl->val == V4L2_EXPOSURE_MANUAL) { unsigned long range = exp->maximum - exp->minimum; - unsigned long shutter = ((exp->val - exp->minimum) * 1048 + + unsigned long shutter = ((exp->val - (s32)exp->minimum) * 1048 + range / 2) / range + 1; dev_dbg(&client->dev, diff --git a/drivers/media/i2c/soc_camera/mt9m111.c b/drivers/media/i2c/soc_camera/mt9m111.c index ccf59406a17..b51e8562e77 100644 --- a/drivers/media/i2c/soc_camera/mt9m111.c +++ b/drivers/media/i2c/soc_camera/mt9m111.c @@ -931,6 +931,12 @@ static int mt9m111_probe(struct i2c_client *client, struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); int ret; + if (client->dev.of_node) { + ssdd = devm_kzalloc(&client->dev, sizeof(*ssdd), GFP_KERNEL); + if (!ssdd) + return -ENOMEM; + client->dev.platform_data = ssdd; + } if (!ssdd) { dev_err(&client->dev, "mt9m111: driver needs platform data\n"); return -EINVAL; @@ -1015,6 +1021,11 @@ static int mt9m111_remove(struct i2c_client *client) return 0; } +static const struct of_device_id mt9m111_of_match[] = { + { .compatible = "micron,mt9m111", }, + {}, +}; +MODULE_DEVICE_TABLE(of, mt9m111_of_match); static const struct i2c_device_id mt9m111_id[] = { { "mt9m111", 0 }, @@ -1025,6 +1036,7 @@ MODULE_DEVICE_TABLE(i2c, mt9m111_id); static struct i2c_driver mt9m111_i2c_driver = { .driver = { .name = "mt9m111", + .of_match_table = of_match_ptr(mt9m111_of_match), }, .probe = mt9m111_probe, .remove = mt9m111_remove, diff --git a/drivers/media/i2c/soc_camera/mt9t031.c b/drivers/media/i2c/soc_camera/mt9t031.c index ee7bb0ffcec..f8358c4071a 100644 --- a/drivers/media/i2c/soc_camera/mt9t031.c +++ b/drivers/media/i2c/soc_camera/mt9t031.c @@ -474,7 +474,7 @@ static int mt9t031_s_ctrl(struct v4l2_ctrl *ctrl) if (ctrl->val <= ctrl->default_value) { /* Pack it into 0..1 step 0.125, register values 0..8 */ unsigned long range = ctrl->default_value - ctrl->minimum; - data = ((ctrl->val - ctrl->minimum) * 8 + range / 2) / range; + data = ((ctrl->val - (s32)ctrl->minimum) * 8 + range / 2) / range; dev_dbg(&client->dev, "Setting gain %d\n", data); data = reg_write(client, MT9T031_GLOBAL_GAIN, data); @@ -485,7 +485,7 @@ static int mt9t031_s_ctrl(struct v4l2_ctrl *ctrl) /* We assume qctrl->maximum - qctrl->default_value - 1 > 0 */ unsigned long range = ctrl->maximum - ctrl->default_value - 1; /* calculated gain: map 65..127 to 9..1024 step 0.125 */ - unsigned long gain = ((ctrl->val - ctrl->default_value - 1) * + unsigned long gain = ((ctrl->val - (s32)ctrl->default_value - 1) * 1015 + range / 2) / range + 9; if (gain <= 32) /* calculated gain 9..32 -> 9..32 */ @@ -507,7 +507,7 @@ static int mt9t031_s_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_EXPOSURE_AUTO: if (ctrl->val == V4L2_EXPOSURE_MANUAL) { unsigned int range = exp->maximum - exp->minimum; - unsigned int shutter = ((exp->val - exp->minimum) * 1048 + + unsigned int shutter = ((exp->val - (s32)exp->minimum) * 1048 + range / 2) / range + 1; u32 old; diff --git a/drivers/media/i2c/soc_camera/mt9v022.c b/drivers/media/i2c/soc_camera/mt9v022.c index f9f95f815b1..99022c8d76e 100644 --- a/drivers/media/i2c/soc_camera/mt9v022.c +++ b/drivers/media/i2c/soc_camera/mt9v022.c @@ -583,7 +583,7 @@ static int mt9v022_s_ctrl(struct v4l2_ctrl *ctrl) /* mt9v022 has minimum == default */ unsigned long range = gain->maximum - gain->minimum; /* Valid values 16 to 64, 32 to 64 must be even. */ - unsigned long gain_val = ((gain->val - gain->minimum) * + unsigned long gain_val = ((gain->val - (s32)gain->minimum) * 48 + range / 2) / range + 16; if (gain_val >= 32) @@ -608,7 +608,7 @@ static int mt9v022_s_ctrl(struct v4l2_ctrl *ctrl) } else { struct v4l2_ctrl *exp = mt9v022->exposure; unsigned long range = exp->maximum - exp->minimum; - unsigned long shutter = ((exp->val - exp->minimum) * + unsigned long shutter = ((exp->val - (s32)exp->minimum) * 479 + range / 2) / range + 1; /* diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c index a9121254e37..193e7d6c29c 100644 --- a/drivers/media/i2c/tvp5150.c +++ b/drivers/media/i2c/tvp5150.c @@ -56,38 +56,29 @@ static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl) static int tvp5150_read(struct v4l2_subdev *sd, unsigned char addr) { struct i2c_client *c = v4l2_get_subdevdata(sd); - unsigned char buffer[1]; int rc; - struct i2c_msg msg[] = { - { .addr = c->addr, .flags = 0, - .buf = &addr, .len = 1 }, - { .addr = c->addr, .flags = I2C_M_RD, - .buf = buffer, .len = 1 } - }; - - rc = i2c_transfer(c->adapter, msg, 2); - if (rc < 0 || rc != 2) { - v4l2_err(sd, "i2c i/o error: rc == %d (should be 2)\n", rc); - return rc < 0 ? rc : -EIO; + + rc = i2c_smbus_read_byte_data(c, addr); + if (rc < 0) { + v4l2_err(sd, "i2c i/o error: rc == %d\n", rc); + return rc; } - v4l2_dbg(2, debug, sd, "tvp5150: read 0x%02x = 0x%02x\n", addr, buffer[0]); + v4l2_dbg(2, debug, sd, "tvp5150: read 0x%02x = 0x%02x\n", addr, rc); - return (buffer[0]); + return rc; } static inline void tvp5150_write(struct v4l2_subdev *sd, unsigned char addr, unsigned char value) { struct i2c_client *c = v4l2_get_subdevdata(sd); - unsigned char buffer[2]; int rc; - buffer[0] = addr; - buffer[1] = value; - v4l2_dbg(2, debug, sd, "tvp5150: writing 0x%02x 0x%02x\n", buffer[0], buffer[1]); - if (2 != (rc = i2c_master_send(c, buffer, 2))) - v4l2_dbg(0, debug, sd, "i2c i/o error: rc == %d (should be 2)\n", rc); + v4l2_dbg(2, debug, sd, "tvp5150: writing 0x%02x 0x%02x\n", addr, value); + rc = i2c_smbus_write_byte_data(c, addr, value); + if (rc < 0) + v4l2_dbg(0, debug, sd, "i2c i/o error: rc == %d\n", rc); } static void dump_reg_range(struct v4l2_subdev *sd, char *s, u8 init, @@ -1148,10 +1139,10 @@ static int tvp5150_probe(struct i2c_client *c, /* Is TVP5150A */ if (tvp5150_id[2] == 3 || tvp5150_id[3] == 0x21) { v4l2_info(sd, "tvp%02x%02xa detected.\n", - tvp5150_id[2], tvp5150_id[3]); + tvp5150_id[0], tvp5150_id[1]); } else { v4l2_info(sd, "*** unknown tvp%02x%02x chip detected.\n", - tvp5150_id[2], tvp5150_id[3]); + tvp5150_id[0], tvp5150_id[1]); v4l2_info(sd, "*** Rom ver is %d.%d\n", tvp5150_id[2], tvp5150_id[3]); } |