Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fps performance improved for vga, poweroff state supported

  • Loading branch information...
commit 64fdae269926c6d1a6c1d48908c702272f1fe20a 1 parent 175ab75
vivek vkmr authored
2  Angstrom/MT9P031/board-omap3beagle-camera.c
@@ -480,7 +480,7 @@ static int mt9p031_power_set(struct v4l2_int_device *s, enum v4l2_power power)
480 480 switch (power) {
481 481 case V4L2_POWER_OFF:
482 482 DPRINTK_CAM_BOARD("-->board-omap3beagle-camera.c::mt9p031_power_set()-->V4L2_POWER_OFF got called\n");
483   - break;
  483 +
484 484 case V4L2_POWER_STANDBY:
485 485 DPRINTK_CAM_BOARD("-->board-omap3beagle-camera.c::mt9p031_power_set()-->V4L2_POWER_STANDBY got called\n");
486 486 isp_set_xclk(vdev->cam->isp, 0, CAM_USE_XCLKA);
633 Angstrom/MT9P031/mt9p031.c
@@ -9,17 +9,21 @@
9 9 *
10 10 * Leverage mt9p012.c
11 11 *
12   - * This file is licensed under the terms of the GNU General Public License
13   - * version 2. This program is licensed "as is" without any warranty of any
14   - * kind, whether express or implied.
  12 + * This program is free software; you can redistribute it and/or modify
  13 + * it under the terms of the GNU General Public License version 2 as
  14 + * published by the Free Software Foundation.
  15 + *
  16 + * This program is distributed in the hope that it will be useful,
  17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19 + * GNU General Public License for more details.
  20 + *
  21 + * You should have received a copy of the GNU General Public License
  22 + * along with this program; if not, write to the Free Software
  23 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  24 + *
15 25 */
16 26
17   -/*
18   - * TODO:
19   - * Verify Preview and Capture for various resolutions[verified for VGA SIZE only]
20   -*/
21   -
22   -
23 27
24 28 #include <linux/delay.h>
25 29 #include <linux/i2c.h>
@@ -64,15 +68,15 @@
64 68 /* FPS Capabilities */
65 69 #define MT9P031_MIN_FPS 10
66 70 #define MT9P031_DEF_FPS 30
67   -#define MT9P031_MAX_FPS 60
  71 +#define MT9P031_MAX_FPS 50
68 72
69 73 #define MT9P031_XCLK_NOM_1 12000000
70 74 #define MT9P031_XCLK_NOM_2 24000000
71 75
72 76 /* Analog gain values */
73 77 #define MT9P031_EV_MIN_GAIN 0
74   -#define MT9P031_EV_MAX_GAIN 56
75   -#define MT9P031_EV_DEF_GAIN 20
  78 +#define MT9P031_EV_MAX_GAIN 47
  79 +#define MT9P031_EV_DEF_GAIN 24
76 80 #define MT9P031_EV_GAIN_STEP 1
77 81
78 82 /* Exposure time values */
@@ -152,10 +156,10 @@ static const unsigned int mt9p031_num_formats = ARRAY_SIZE(mt9p031_formats);
152 156
153 157 /***********************Minimum Horizontal blanking*********************/
154 158 int hb_min[4][4] = {
155   - { 450, 430, 0, 420 },
156   - { 796, 776, 0, 766 },
157   - { 0, 0, 0, 0 },
158   - { 1488, 1468, 0, 1458 },
  159 + { 450, 430, 0, 420 },
  160 + { 796, 776, 0, 766 },
  161 + { 0, 0, 0, 0 },
  162 + { 1488, 1468, 0, 1458 },
159 163 };
160 164
161 165 /**************************supported sizes******************************/
@@ -200,13 +204,13 @@ enum mt9p031_image_size {
200 204 enum mt9p031_image_size mt9p031_current_format;
201 205
202 206 const struct mt9p031_format_params mt9p031_supported_formats[] = {
203   - { 640, 480, 0x0040, 0x0080, 0x0778, 0x09F8, 0, 0, 0x0296, 0x0033, 0x0033, 0x0060, 0, 0, 3, 3 }, // VGA_BIN_30FPS
204   - { 1280, 720, 0x0040, 0x0018, 0x059F, 0x09FF, 0, 0, 0x0296, 0x0011, 0x0011, 0x0060, 0, 0, 1, 1 }, // 720P_HD_30FPS
205   - //{ 1280, 720, 0x0040, 0x0018, 0x059F, 0x09FF, 0, 0, 0x0296, 0x0011, 0x0011, 0x0060, 0, 0, 1, 1 }, // 720P_HD_60FPS
206   - //{ 1280, 720, 0x0040, 0x0018, 0x059F, 0x09FF, 0, 0x02D0, 0x0296, 0x0011, 0x0011, 0x0060, 0, 0, 1, 1 }, // 720P_HD_60FPS_LVB
207   - { 1920, 1080, 431, 335, 1079, 1919, 0, 0x0037, 0x01AC, 0, 0, 0x0040, 0, 0, 0, 0 }, // 1080P_30FPS
208   - { 2048, 1536, 431, 335, 1535, 2047, 0, 0x0037, 0x01AC, 0, 0, 0x0040, 0, 0, 0, 0 }, // 3MP CAPTURE
209   - { 2592, 1944, 431, 335, 1943, 2591, 0, 0x0037, 0x01AC, 0, 0, 0x0040, 0, 0, 0, 0 }, // 5MP CAPTURE
  207 + { 640, 480, 64, 24, 1919, 2559, 0, 0, 0x0296, 0x0033, 0x0033, 0x0060, 0, 0, 3, 3 }, // VGA_BIN_30FPS
  208 + { 1280, 720, 64, 24, 1439, 2559, 0, 0, 0x0296, 0x0011, 0x0011, 0x0060, 0, 0, 1, 1 }, // 720P_HD_30FPS
  209 + //{ 1280, 720, 0x0040, 0x0018, 0x059F, 0x09FF, 0, 0, 0x0296, 0x0011, 0x0011, 0x0060, 0, 0, 1, 1 }, // 720P_HD_60FPS
  210 + //{ 1280, 720, 0x0040, 0x0018, 0x059F, 0x09FF, 0, 0x02D0, 0x0296, 0x0011, 0x0011, 0x0060, 0, 0, 1, 1 }, // 720P_HD_60FPS_LVB
  211 + { 1920, 1080, 431, 335, 1079, 1919, 0, 0x0037, 0x01AC, 0, 0, 0x0040, 0, 0, 0, 0 }, // 1080P_30FPS
  212 + { 2048, 1536, 431, 335, 1535, 2047, 0, 0x0037, 0x01AC, 0, 0, 0x0040, 0, 0, 0, 0 }, // 3MP CAPTURE
  213 + { 2592, 1944, 431, 335, 1943, 2591, 0, 0x0037, 0x01AC, 0, 0, 0x0040, 0, 0, 0, 0 }, // 5MP CAPTURE
210 214 };
211 215
212 216
@@ -219,7 +223,7 @@ const struct v4l2_fract mt9p031_frameintervals[] = {
219 223 };
220 224
221 225
222   -const u16 MT9P031_EV_GAIN_TBL[57] = {
  226 +const u16 MT9P031_EV_GAIN_TBL[48] = {
223 227 /* Gain x1 */
224 228 8, 9, 10, 11, 12, 13, 14, 15,
225 229 /* Gain x2 */
@@ -227,9 +231,9 @@ const u16 MT9P031_EV_GAIN_TBL[57] = {
227 231 /* Gain x3 */
228 232 24, 25, 26, 27, 28, 29, 30, 31,
229 233 /* Gain x4 */
230   - 32, 33, 34, 35, 72, 73, 74, 75,
  234 + 32, 33, 34, 35,
231 235 /* Gain x5 */
232   - 76, 77, 78, 79, 80, 81, 82, 83,
  236 + 81, 82, 83,
233 237 /* Gain x6 */
234 238 84, 85, 86, 87, 88, 89, 90, 91,
235 239 /* Gain x7 */
@@ -341,83 +345,6 @@ static int mt9p031_reg_write(const struct i2c_client *client,
341 345 }
342 346
343 347 /**
344   - * mt9p031_init_camera - initialize camera settings
345   - * @client: pointer to i2c client
346   - * Initialize camera settings
347   - */
348   -static int mt9p031_init_camera(const struct i2c_client *client)
349   -{
350   - int ret;
351   -
352   - ret = mt9p031_reg_write(client, REG_MT9P031_RESET, 0x0001); //High
353   - ret |= mt9p031_reg_write(client, REG_MT9P031_RESET, 0x0000); //Low
354   - mdelay(100);
355   -
356   - ret |= mt9p031_reg_write(client, REG_MT9P031_SHUTTER_WIDTH_U, 0x0000); //Shutter_width_U
357   - ret |= mt9p031_reg_write(client, REG_MT9P031_SHUTTER_WIDTH_L, 0x00E6); //shutter_width_L
358   - ret |= mt9p031_reg_write(client, REG_MT9P031_SHUTTER_DELAY, 0x0613); //shutter_delay_reg
359   - ret |= mt9p031_reg_write(client, REG_MT9P031_GREEN_1_GAIN, 0x0051); //Green1_gain_reg
360   - ret |= mt9p031_reg_write(client, REG_MT9P031_BLUE_GAIN, 0x0058); //Blue_gain_reg
361   - ret |= mt9p031_reg_write(client, REG_MT9P031_RED_GAIN, 0x0053); //Red_gain_reg
362   - ret |= mt9p031_reg_write(client, REG_MT9P031_GREEN_2_GAIN, 0x0051); //Green2_gain_reg
363   - ret |= mt9p031_reg_write(client, REG_MT9P031_READ_MODE1, 0x0006); //Read_mode_1 //disable AB
364   - ret |= mt9p031_reg_write(client, REG_MT9P031_HBLANK, 0x0600); //Horz_blznk_reg = 1536
365   -
366   - ret |= mt9p031_reg_write(client, REG_MT9P031_PLL_CTRL, 0x0051); //PLL_CTRL; power up pll
367   - ret |= mt9p031_reg_write(client, REG_MT9P031_PLL_CONF1, 0x1801); //PLL_CONFIG_1: m=24, n=1
368   - ret |= mt9p031_reg_write(client, REG_MT9P031_PLL_CONF2, 0x0002); //PLL_CONFIG_2: p1=2, p2=0
369   -
370   - mdelay(10); //wait 10 ms for VCO to lock
371   - ret |= mt9p031_reg_write(client, REG_MT9P031_PLL_CTRL, 0x0053); //PLL_CONTROL; use PLL
372   - mdelay(200);
373   -
374   - ret |= mt9p031_reg_write(client, REG_MT9P031_HBLANK, 0x01C2); //Horz_blank_reg
375   - ret |= mt9p031_reg_write(client, REG_MT9P031_OUT_CTRL, 0x1F8E); //Enable parll fifo data
376   - ret |= mt9p031_reg_write(client, REG_MT9P031_SHUTTER_WIDTH_L, 0x1000); //Shutter width lower; integration time register
377   -
378   - return ret>= 0 ? 0 : -EIO;
379   -}
380   -
381   -/**
382   - * mt9p031_sublevel_optimization - sublevel optimization
383   - * @client: pointer to i2c client
384   - */
385   -static int mt9p031_sublevel_optimization(struct i2c_client *client)
386   -{
387   - int ret;
388   -
389   - ret = mt9p031_reg_write(client, 0x70, 0x5C);
390   - ret |= mt9p031_reg_write(client, 0x71, 0x5B00);
391   - ret |= mt9p031_reg_write(client, 0x72, 0x5900);
392   - ret |= mt9p031_reg_write(client, 0x73, 0x200);
393   - ret |= mt9p031_reg_write(client, 0x74, 0x200);
394   - ret |= mt9p031_reg_write(client, 0x75, 0x2800);
395   - ret |= mt9p031_reg_write(client, 0x76, 0x3E29);
396   - ret |= mt9p031_reg_write(client, 0x77, 0x3E29);
397   - ret |= mt9p031_reg_write(client, 0x78, 0x583F);
398   - ret |= mt9p031_reg_write(client, 0x79, 0x5B00);
399   - ret |= mt9p031_reg_write(client, 0x7a, 0x5A00);
400   - ret |= mt9p031_reg_write(client, 0x7b, 0x5900);
401   - ret |= mt9p031_reg_write(client, 0x7c, 0x5900);
402   - ret |= mt9p031_reg_write(client, 0x7e, 0x5900);
403   - ret |= mt9p031_reg_write(client, 0x7f, 0x5900);
404   - ret |= mt9p031_reg_write(client, 0x6, 0x0);
405   - ret |= mt9p031_reg_write(client, 0x29, 0x481);
406   - ret |= mt9p031_reg_write(client, 0x3e, 0x87);
407   - ret |= mt9p031_reg_write(client, 0x3f, 0x7);
408   - ret |= mt9p031_reg_write(client, 0x41, 0x3);
409   - ret |= mt9p031_reg_write(client, 0x48, 0x18);
410   - ret |= mt9p031_reg_write(client, 0x5f, 0x1C16);
411   - ret |= mt9p031_reg_write(client, 0x57, 0x7);
412   - ret |= mt9p031_reg_write(client, 0x2A, 0xFF74);
413   -
414   - if (ret < 0)
415   - ret = 0;
416   -
417   - return ret;
418   -}
419   -
420   -/**
421 348 * struct vcontrol - Video controls
422 349 * @v4l2_queryctrl: V4L2 VIDIOC_QUERYCTRL ioctl structure
423 350 * @current_value: current value of this control
@@ -534,7 +461,6 @@ static unsigned long mt9p031_calc_xclk(struct i2c_client *c)
534 461 {
535 462 struct mt9p031_priv *priv = i2c_get_clientdata(c);
536 463 struct v4l2_fract *timeperframe = &priv->timeperframe;
537   - struct v4l2_pix_format *pix = &priv->pix;
538 464
539 465 if (timeperframe->numerator == 0 ||
540 466 timeperframe->denominator == 0) {
@@ -552,12 +478,77 @@ static unsigned long mt9p031_calc_xclk(struct i2c_client *c)
552 478 timeperframe->numerator = 1;
553 479 timeperframe->denominator = priv->fps;
554 480
555   - if ((pix->width <= VGA_WIDTH) && (priv->fps > 15))
556   - return MT9P031_XCLK_NOM_2;
557   -
558 481 return MT9P031_XCLK_NOM_1;
559 482 }
560 483
  484 +/**
  485 + * mt9p031_set_params - sets register settings according to resolution
  486 + * @client: pointer to standard i2c client
  487 + * @width: width as queried by ioctl
  488 + * @height: height as queried by ioctl
  489 + */
  490 +static int mt9p031_set_params(struct i2c_client *client, u32 width, u32 height)
  491 +{
  492 + struct mt9p031_priv *priv = i2c_get_clientdata(client);
  493 + struct v4l2_pix_format *pix = &priv->pix;
  494 + int ret;
  495 + enum mt9p031_image_size i;
  496 +
  497 + i = mt9p031_find_isize(pix->width);
  498 + priv->pix.width = mt9p031_supported_formats[i].width;
  499 + priv->pix.height = mt9p031_supported_formats[i].height;
  500 +
  501 + ret = mt9p031_reg_write(client, REG_MT9P031_ROWSTART, mt9p031_supported_formats[i].row_start); //ROW_WINDOW_START_REG
  502 + ret |= mt9p031_reg_write(client, REG_MT9P031_COLSTART, mt9p031_supported_formats[i].col_start); //COL_WINDOW_START_REG
  503 + ret |= mt9p031_reg_write(client, REG_MT9P031_HEIGHT, mt9p031_supported_formats[i].row_size); //ROW_WINDOW_SIZE_REG=1439
  504 + ret |= mt9p031_reg_write(client, REG_MT9P031_WIDTH, mt9p031_supported_formats[i].col_size); //COL_WINDOW_SIZE_REG=2559
  505 + ret |= mt9p031_reg_write(client, REG_MT9P031_HBLANK, mt9p031_supported_formats[i].hblank); //HORZ_BLANK=0
  506 + ret |= mt9p031_reg_write(client, REG_MT9P031_VBLANK, mt9p031_supported_formats[i].vblank); //VERT_BLANK_REG=720
  507 + ret |= mt9p031_reg_write(client, REG_MT9P031_SHUTTER_WIDTH_L, 0x0400); //SHUTTER_WIDTH_LOW (INTEG_TIME_REG = 1024)
  508 + ret |= mt9p031_reg_write(client, REG_MT9P031_ROW_ADDR_MODE, mt9p031_supported_formats[i].row_addr_mode); //ROW_MODE, ROW_SKIP=1, ROW_BIN=1
  509 + ret |= mt9p031_reg_write(client, REG_MT9P031_COL_ADDR_MODE, mt9p031_supported_formats[i].col_addr_mode); //COL_MODE, COL_SKIP=1, COL_BIN=1
  510 + ret |= mt9p031_reg_write(client, REG_MT9P031_READ_MODE2, mt9p031_supported_formats[i].read_mode_2_config); //READ_MODE_2, COL_SUM
  511 + ret |= mt9p031_reg_write(client, REG_MT9P031_SHUTTER_WIDTH_U, mt9p031_supported_formats[i].shutter_width_hi); //SHUTTER_WIDTH_HI
  512 + ret |= mt9p031_reg_write(client, REG_MT9P031_SHUTTER_WIDTH_L, mt9p031_supported_formats[i].integ_time); //SHUTTER_WIDTH_LOW (INTEG_TIME_REG)
  513 + ret |= mt9p031_reg_write(client, REG_MT9P031_SHUTTER_DELAY, mt9p031_supported_formats[i].shutter_delay); //SHUTTER_DELAY_REG
  514 +
  515 + return ret;
  516 +}
  517 +
  518 +/**
  519 + * mt9p031_init_camera - initialize camera settings
  520 + * @client: pointer to i2c client
  521 + * Initialize camera settings
  522 + */
  523 +static int mt9p031_init_camera(const struct i2c_client *client)
  524 +{
  525 + int ret;
  526 + struct mt9p031_priv *priv = i2c_get_clientdata(client);
  527 + struct v4l2_pix_format *pix = &priv->pix;
  528 +
  529 + ret = mt9p031_reg_write(client, REG_MT9P031_PLL_CTRL, 0x0051); //PLL_CTRL; power up pll
  530 + ret |= mt9p031_reg_write(client, REG_MT9P031_PLL_CONF1, 0x1801); //PLL_CONFIG_1: m=24, n=1
  531 + ret |= mt9p031_reg_write(client, REG_MT9P031_PLL_CONF2, 0x0002); //PLL_CONFIG_2: p1=2, p2=0
  532 + mdelay(10); //wait 10 ms for VCO to lock
  533 + ret |= mt9p031_reg_write(client, REG_MT9P031_PLL_CTRL, 0x0053); //PLL_CONTROL; use PLL
  534 + mdelay(200);
  535 +
  536 + ret |= mt9p031_set_params(priv->client, pix->width, pix->height);
  537 +
  538 + ret |= mt9p031_reg_write(client, REG_MT9P031_RESET, 0x0001); //High
  539 + ret |= mt9p031_reg_write(client, REG_MT9P031_RESET, 0x0000); //Low
  540 + mdelay(100);
  541 +
  542 + ret |= mt9p031_reg_write(client, REG_MT9P031_GREEN_1_GAIN, 0x0051); //Green1_gain_reg
  543 + ret |= mt9p031_reg_write(client, REG_MT9P031_BLUE_GAIN, 0x0051); //Blue_gain_reg
  544 + ret |= mt9p031_reg_write(client, REG_MT9P031_RED_GAIN, 0x0051); //Red_gain_reg
  545 + ret |= mt9p031_reg_write(client, REG_MT9P031_GREEN_2_GAIN, 0x0051); //Green2_gain_reg
  546 + ret |= mt9p031_reg_write(client, REG_MT9P031_READ_MODE1, 0x0006); //Read_mode_1 //disable AB
  547 + ret |= mt9p031_reg_write(client, REG_MT9P031_OUT_CTRL, 0x1F8E); //Enable parll fifo data
  548 +
  549 + return ret>= 0 ? 0 : -EIO;
  550 +}
  551 +
561 552 /************************************************************************
562 553 i2c driver
563 554 ************************************************************************/
@@ -589,7 +580,6 @@ static int mt9p031_detect(struct i2c_client *client)
589 580 if(chipid == MT9P031_CHIP_ID) {
590 581 devname = "mt9p031";
591 582 priv->model = V4L2_IDENT_MT9P031;
592   - DPRINTK_DRIVER("Chip ID Read Successful 0x%x\n", chipid);
593 583 dev_info(&client->dev, "%s chip ID %04x\n", devname, chipid);
594 584 return 0;
595 585 }
@@ -599,59 +589,6 @@ static int mt9p031_detect(struct i2c_client *client)
599 589 }
600 590
601 591 /**
602   - * mt9p031_set_params - sets register settings according to resolution
603   - * @client: pointer to standard i2c client
604   - * @width: width as queried by ioctl
605   - * @height: height as queried by ioctl
606   - * @pixelformat:
607   - * finds and sets current format and its settings to corresponding registers
608   - */
609   -static int mt9p031_set_params(struct i2c_client *client, u32 width, u32 height,
610   - u32 pixelformat)
611   -{
612   - struct mt9p031_priv *priv = i2c_get_clientdata(client);
613   - int ret;
614   - enum mt9p031_image_size i = 0;
615   -
616   - priv->pix.width = (u16)width;
617   - priv->pix.height = (u16)height;
618   -
619   - priv->pix.pixelformat = pixelformat;
620   -
621   - /*if(width == 640 && height == 480)
622   - i = VGA_BIN_30FPS;
623   - else if(width == 1280 && height == 720)
624   - i = HDV_720P_30FPS;
625   - else if(width == 1920 && height == 1080)
626   - i = HDV_1080P_30FPS;
627   -
628   - mt9p031_current_format = i;*/
629   - i = mt9p031_current_format;
630   -
631   - priv->pix.width = mt9p031_supported_formats[i].width;
632   - priv->pix.height = mt9p031_supported_formats[i].height;
633   -
634   - ret = mt9p031_reg_write(client, REG_MT9P031_ROWSTART, mt9p031_supported_formats[i].row_start); //ROW_WINDOW_START_REG
635   - ret |= mt9p031_reg_write(client, REG_MT9P031_COLSTART, mt9p031_supported_formats[i].col_start); //COL_WINDOW_START_REG
636   - ret |= mt9p031_reg_write(client, REG_MT9P031_HEIGHT, mt9p031_supported_formats[i].row_size); //ROW_WINDOW_SIZE_REG=1439
637   - ret |= mt9p031_reg_write(client, REG_MT9P031_WIDTH, mt9p031_supported_formats[i].col_size); //COL_WINDOW_SIZE_REG=2559
638   - ret |= mt9p031_reg_write(client, REG_MT9P031_HBLANK, mt9p031_supported_formats[i].hblank); //HORZ_BLANK=0
639   - ret |= mt9p031_reg_write(client, REG_MT9P031_VBLANK, mt9p031_supported_formats[i].vblank); //VERT_BLANK_REG=720
640   - ret |= mt9p031_reg_write(client, REG_MT9P031_SHUTTER_WIDTH_L, 0x0400); //SHUTTER_WIDTH_LOW (INTEG_TIME_REG = 1024)
641   - ret |= mt9p031_reg_write(client, REG_MT9P031_ROW_ADDR_MODE, mt9p031_supported_formats[i].row_addr_mode); //ROW_MODE, ROW_SKIP=1, ROW_BIN=1
642   - ret |= mt9p031_reg_write(client, REG_MT9P031_COL_ADDR_MODE, mt9p031_supported_formats[i].col_addr_mode); //COL_MODE, COL_SKIP=1, COL_BIN=1
643   - ret |= mt9p031_reg_write(client, REG_MT9P031_READ_MODE2, mt9p031_supported_formats[i].read_mode_2_config); //READ_MODE_2, COL_SUM
644   - ret |= mt9p031_reg_write(client, REG_MT9P031_SHUTTER_WIDTH_U, mt9p031_supported_formats[i].shutter_width_hi); //SHUTTER_WIDTH_HI
645   - ret |= mt9p031_reg_write(client, REG_MT9P031_SHUTTER_WIDTH_L, mt9p031_supported_formats[i].integ_time); //SHUTTER_WIDTH_LOW (INTEG_TIME_REG)
646   - ret |= mt9p031_reg_write(client, REG_MT9P031_SHUTTER_DELAY, mt9p031_supported_formats[i].shutter_delay); //SHUTTER_DELAY_REG
647   -
648   - //Sub-Sample optimization
649   - ret |= mt9p031_sublevel_optimization(client);
650   -
651   - return ret;
652   -}
653   -
654   -/**
655 592 * mt9p031_set_exposure_time - sets exposure time per input value
656 593 * @exp_time: exposure time to be set on device
657 594 * @client: pointer to standard i2c client
@@ -679,8 +616,7 @@ static int mt9p031_set_exposure_time(u32 exp_time, struct i2c_client *client,
679 616 so_p = 208 * (mt9p031_supported_formats[mt9p031_current_format].row_bin + 1) + 98 + sd_p - 94;
680 617 t_pix_clk = (Q12/96 );
681 618 h_blanking = mt9p031_supported_formats[mt9p031_current_format].hblank + 1;
682   - W = (mt9p031_supported_formats[mt9p031_current_format].width + 1) / (mt9p031_supported_formats[mt9p031_current_format].row_bin + 1);
683   -
  619 + W = 2 * (int)((mt9p031_supported_formats[mt9p031_current_format].row_size + 1) / (2 * (mt9p031_supported_formats[mt9p031_current_format].row_bin + 1)) + 1);
684 620 t_row = 2 * t_pix_clk * max(W/2 + max(h_blanking, hb_min[mt9p031_supported_formats[mt9p031_current_format].row_bin][mt9p031_supported_formats[mt9p031_current_format].col_bin]),
685 621 (41 + 346 * (mt9p031_supported_formats[mt9p031_current_format].row_bin + 1) + 99))/Q12;
686 622
@@ -763,55 +699,6 @@ int mt9p031_set_gain(u16 lineargain, struct i2c_client *client,
763 699 /************************************************************************
764 700 v4l2_ioctls
765 701 ************************************************************************/
766   -/**
767   - * mt9p031_v4l2_int_s_parm - V4L2 sensor interface handler for VIDIOC_S_PARM ioctl
768   - * @s: pointer to standard V4L2 device structure
769   - * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure
770   - *
771   - * Configures the sensor to use the input parameters, if possible. If
772   - * not possible, reverts to the old parameters and returns the
773   - * appropriate error code.
774   - */
775   -
776   -
777   -static int mt9p031_v4l2_int_s_parm(struct v4l2_int_device *s,
778   - struct v4l2_streamparm *a)
779   -{
780   - struct mt9p031_priv *priv = s->priv;
781   - struct i2c_client *client = priv->client;
782   - struct v4l2_fract *timeperframe = &a->parm.capture.timeperframe;
783   -
784   - priv->timeperframe = *timeperframe;
785   - priv->xclk_current = mt9p031_calc_xclk(client);
786   - *timeperframe = priv->timeperframe;
787   -
788   - return 0;
789   -}
790   -
791   -/**
792   - * mt9p031_v4l2_int_g_parm - V4L2 sensor interface handler for VIDIOC_G_PARM ioctl
793   - * @s: pointer to standard V4L2 device structure
794   - * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure
795   - *
796   - * Returns the sensor's video CAPTURE parameters.
797   - */
798   -static int mt9p031_v4l2_int_g_parm(struct v4l2_int_device *s,
799   - struct v4l2_streamparm *a)
800   -{
801   - struct v4l2_captureparm *cparm = &a->parm.capture;
802   -
803   - if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
804   - return -EINVAL;
805   -
806   - memset(a, 0, sizeof(*a));
807   - a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
808   -
809   - cparm->capability = V4L2_CAP_TIMEPERFRAME;
810   - cparm->timeperframe.numerator = 1;
811   - cparm->timeperframe.denominator = 30;
812   -
813   - return 0;
814   -}
815 702
816 703 /**
817 704 * mt9p031_v4l2_int_s_power - V4L2 sensor interface handler for vidioc_int_s_power_num
@@ -867,70 +754,70 @@ static int mt9p031_v4l2_int_s_power(struct v4l2_int_device *s,
867 754 }
868 755
869 756 /**
870   - * mt9p031_v4l2_g_ctrl - V4L2 sensor interface handler for VIDIOC_G_CTRL ioctl
  757 + * mt9p031_v4l2_s_ctrl - V4L2 sensor interface handler for VIDIOC_S_CTRL ioctl
871 758 * @s: pointer to standard V4L2 device structure
872   - * @vc: standard V4L2 VIDIOC_G_CTRL ioctl structure
  759 + * @vc: standard V4L2 VIDIOC_S_CTRL ioctl structure
873 760 *
874   - * If the requested control is supported, returns the control's current
875   - * value from the video_control[] array. Otherwise, returns -EINVAL
876   - * if the control is not supported.
  761 + * If the requested control is supported, sets the control's current
  762 + * value in HW (and updates the video_control[] array). Otherwise,
  763 + * returns -EINVAL if the control is not supported.
877 764 */
878   -static int mt9p031_v4l2_g_ctrl(struct v4l2_int_device *s,
  765 +static int mt9p031_v4l2_s_ctrl(struct v4l2_int_device *s,
879 766 struct v4l2_control *vc)
880 767 {
881   - struct vcontrol *lvc;
  768 + int retval = -EINVAL;
882 769 int i;
883   -
  770 + struct vcontrol *lvc;
  771 + struct mt9p031_priv *priv = s->priv;
  772 + struct i2c_client *client = priv->client;
  773 +
884 774 i = find_vctrl(vc->id);
885 775 if (i < 0)
886 776 return -EINVAL;
887 777 lvc = &mt9p031_video_control[i];
888 778
889 779 switch (vc->id) {
890   - case V4L2_CID_EXPOSURE:
891   - vc->value = lvc->current_value;
  780 + case V4L2_CID_EXPOSURE:
  781 + retval = mt9p031_set_exposure_time(vc->value, client, lvc);
892 782 break;
893 783 case V4L2_CID_GAIN:
894   - vc->value = lvc->current_value;
  784 + retval = mt9p031_set_gain(vc->value, client, lvc);
895 785 break;
896 786 }
897 787
898   - return 0;
  788 + return retval;
899 789 }
900 790
901 791 /**
902   - * mt9p031_v4l2_s_ctrl - V4L2 sensor interface handler for VIDIOC_S_CTRL ioctl
  792 + * mt9p031_v4l2_g_ctrl - V4L2 sensor interface handler for VIDIOC_G_CTRL ioctl
903 793 * @s: pointer to standard V4L2 device structure
904   - * @vc: standard V4L2 VIDIOC_S_CTRL ioctl structure
  794 + * @vc: standard V4L2 VIDIOC_G_CTRL ioctl structure
905 795 *
906   - * If the requested control is supported, sets the control's current
907   - * value in HW (and updates the video_control[] array). Otherwise,
908   - * returns -EINVAL if the control is not supported.
  796 + * If the requested control is supported, returns the control's current
  797 + * value from the video_control[] array. Otherwise, returns -EINVAL
  798 + * if the control is not supported.
909 799 */
910   -static int mt9p031_v4l2_s_ctrl(struct v4l2_int_device *s,
  800 +static int mt9p031_v4l2_g_ctrl(struct v4l2_int_device *s,
911 801 struct v4l2_control *vc)
912 802 {
913   - int retval = -EINVAL;
914   - int i;
915 803 struct vcontrol *lvc;
916   - struct mt9p031_priv *priv = s->priv;
917   - struct i2c_client *client = priv->client;
918   -
  804 + int i;
  805 +
919 806 i = find_vctrl(vc->id);
920 807 if (i < 0)
921 808 return -EINVAL;
922 809 lvc = &mt9p031_video_control[i];
923 810
924 811 switch (vc->id) {
925   - case V4L2_CID_EXPOSURE:
926   - retval = mt9p031_set_exposure_time(vc->value, client, lvc);
  812 + case V4L2_CID_EXPOSURE:
  813 + vc->value = lvc->current_value;
927 814 break;
928 815 case V4L2_CID_GAIN:
929   - retval = mt9p031_set_gain(vc->value, client, lvc);
  816 + vc->value = lvc->current_value;
930 817 break;
931 818 }
932 819
933   - return retval;
  820 + return 0;
934 821 }
935 822
936 823 /**
@@ -957,50 +844,42 @@ static int mt9p031_v4l2_queryctrl(struct v4l2_int_device *s, struct v4l2_queryct
957 844 return 0;
958 845 }
959 846
960   -/**
961   - * mt9p031_v4l2_int_g_priv - V4L2 sensor interface handler for vidioc_int_g_priv_num
962   - * @s: pointer to standard V4L2 device structure
963   - * @p: void pointer to hold sensor's private data address
964   - *
965   - * Returns device's (sensor's) private data area address in p parameter
966   - */
967   -static int mt9p031_v4l2_int_g_priv(struct v4l2_int_device *s, void *p)
968   -{
969   - struct mt9p031_priv *priv = s->priv;
970   -
971   - return priv->pdata->priv_data_set(p);
972   -}
973 847
974 848 /**
975   - * mt9p031_v4l2_int_g_ifparm - V4L2 sensor interface handler for vidioc_int_g_priv_num
  849 + * mt9p031_v4l2_int_enum_fmt_cap - Implement the CAPTURE buffer VIDIOC_ENUM_FMT ioctl
976 850 * @s: pointer to standard V4L2 device structure
977   - * @p: void pointer to hold sensor's ifparm
  851 + * @fmt: standard V4L2 VIDIOC_ENUM_FMT ioctl structure
978 852 *
979   - * Returns device's (sensor's) ifparm in p parameter
  853 + * Implement the VIDIOC_ENUM_FMT ioctl for the CAPTURE buffer type.
980 854 */
981   -static int mt9p031_v4l2_int_g_ifparm(struct v4l2_int_device *s,
982   - struct v4l2_ifparm *p)
  855 +static int mt9p031_v4l2_int_enum_fmt_cap(struct v4l2_int_device *s,
  856 + struct v4l2_fmtdesc *fmt)
983 857 {
984   - struct mt9p031_priv *priv = s->priv;
985   - int rval;
  858 + int index = fmt->index;
  859 + enum v4l2_buf_type type = fmt->type;
986 860
987   - if (p == NULL)
988   - return -EINVAL;
  861 + memset(fmt, 0, sizeof(*fmt));
  862 + fmt->index = index;
  863 + fmt->type = type;
989 864
990   - if (!priv->pdata->ifparm)
  865 + switch (fmt->type) {
  866 + case V4L2_BUF_TYPE_VIDEO_CAPTURE:
  867 + if (index >= ARRAY_SIZE(mt9p031_formats))
  868 + return -EINVAL;
  869 + break;
  870 + default:
991 871 return -EINVAL;
992   -
993   - rval = priv->pdata->ifparm(p);
994   - if (rval) {
995   - v4l_err(priv->client, "g_ifparm.Err[%d]\n", rval);
996   - return rval;
997 872 }
998 873
  874 + strlcpy(fmt->description, mt9p031_formats[index].description,
  875 + sizeof(fmt->description));
  876 + fmt->pixelformat = mt9p031_formats[index].pixelformat;
  877 +
999 878 return 0;
1000 879 }
1001 880
1002 881 /**
1003   - * imt9p031_v4l2_int_try_fmt_cap - Implement the CAPTURE buffer VIDIOC_TRY_FMT ioctl
  882 + * mt9p031_v4l2_int_try_fmt_cap - Implement the CAPTURE buffer VIDIOC_TRY_FMT ioctl
1004 883 * @s: pointer to standard V4L2 device structure
1005 884 * @f: pointer to standard V4L2 VIDIOC_TRY_FMT ioctl structure
1006 885 *
@@ -1036,14 +915,8 @@ static int mt9p031_v4l2_int_try_fmt_cap(struct v4l2_int_device *s,
1036 915 pix->colorspace = V4L2_COLORSPACE_SRGB;
1037 916
1038 917 *pix2 = *pix;
1039   - return 0;
1040   -/*
1041   - f->fmt.pix.width = mt9p031_supported_formats[mt9p031_current_format].width;
1042   - f->fmt.pix.height = mt9p031_supported_formats[mt9p031_current_format].height;
1043   - f->fmt.pix.field = V4L2_FIELD_NONE;
1044   - f->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB;
1045 918
1046   - return 0;*/
  919 + return 0;
1047 920 }
1048 921
1049 922 /**
@@ -1059,95 +932,157 @@ static int mt9p031_v4l2_int_s_fmt_cap(struct v4l2_int_device *s,
1059 932 struct v4l2_format *f)
1060 933 {
1061 934 struct mt9p031_priv *priv = s->priv;
1062   - struct i2c_client *client = priv->client;
  935 + struct v4l2_pix_format *pix = &f->fmt.pix;
  936 + int rval;
  937 +
  938 + rval = mt9p031_v4l2_int_try_fmt_cap(s, f);
  939 + if (!rval)
  940 + priv->pix = *pix;
  941 +
  942 + return rval;
  943 +}
  944 +
  945 +/**
  946 + * mt9p031_v4l2_int_g_fmt_cap - V4L2 sensor interface handler for ioctl_g_fmt_cap
  947 + * @s: pointer to standard V4L2 device structure
  948 + * @f: pointer to standard V4L2 v4l2_format structure
  949 + *
  950 + * Returns the sensor's current pixel format in the v4l2_format
  951 + * parameter.
  952 + */
  953 +static int mt9p031_v4l2_int_g_fmt_cap(struct v4l2_int_device *s,
  954 + struct v4l2_format *f)
  955 +{
  956 + struct mt9p031_priv *priv = s->priv;
  957 +
  958 + f->fmt.pix.width = priv->pix.width;
  959 + f->fmt.pix.height = priv->pix.height;
  960 + f->fmt.pix.pixelformat = V4L2_COLORSPACE_SRGB;
  961 + f->fmt.pix.pixelformat = priv->pix.pixelformat;
  962 + f->fmt.pix.field = V4L2_FIELD_NONE;
1063 963
1064   - mt9p031_v4l2_int_try_fmt_cap(s, f);
1065   - return mt9p031_set_params(client, f->fmt.pix.width, f->fmt.pix.height,
1066   - f->fmt.pix.pixelformat);
  964 + return 0;
1067 965 }
1068 966
1069 967 /**
1070   - * mt9p031_v4l2_int_enum_framesizes - V4L2 sensor if handler for vidioc_int_enum_framesizes
  968 + * mt9p031_v4l2_int_s_parm - V4L2 sensor interface handler for VIDIOC_S_PARM ioctl
1071 969 * @s: pointer to standard V4L2 device structure
1072   - * @frms: pointer to standard V4L2 framesizes enumeration structure
  970 + * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure
1073 971 *
1074   - * Returns possible framesizes depending on choosen pixel format
  972 + * Configures the sensor to use the input parameters, if possible. If
  973 + * not possible, reverts to the old parameters and returns the
  974 + * appropriate error code.
1075 975 */
1076   -static int mt9p031_v4l2_int_enum_framesizes(struct v4l2_int_device *s,
1077   - struct v4l2_frmsizeenum *frms)
  976 +
  977 +
  978 +static int mt9p031_v4l2_int_s_parm(struct v4l2_int_device *s,
  979 + struct v4l2_streamparm *a)
1078 980 {
1079   - int ifmt;
  981 + struct mt9p031_priv *priv = s->priv;
  982 + struct i2c_client *client = priv->client;
  983 + struct v4l2_fract *timeperframe = &a->parm.capture.timeperframe;
1080 984
1081   - for (ifmt = 0; ifmt < ARRAY_SIZE(mt9p031_formats); ifmt++)
1082   - if (mt9p031_formats[ifmt].pixelformat == frms->pixel_format)
1083   - break;
  985 + priv->timeperframe = *timeperframe;
  986 + priv->xclk_current = mt9p031_calc_xclk(client);
  987 + *timeperframe = priv->timeperframe;
1084 988
1085   - if (ifmt == ARRAY_SIZE(mt9p031_formats))
1086   - return -EINVAL;
  989 + return 0;
  990 +}
1087 991
1088   - /* Do we already reached all discrete framesizes? */
1089   - if (frms->index >= ARRAY_SIZE(mt9p031_sizes))
  992 +/**
  993 + * mt9p031_v4l2_int_g_parm - V4L2 sensor interface handler for VIDIOC_G_PARM ioctl
  994 + * @s: pointer to standard V4L2 device structure
  995 + * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure
  996 + *
  997 + * Returns the sensor's video CAPTURE parameters.
  998 + */
  999 +static int mt9p031_v4l2_int_g_parm(struct v4l2_int_device *s,
  1000 + struct v4l2_streamparm *a)
  1001 +{
  1002 + struct mt9p031_priv *priv = s->priv;
  1003 + struct v4l2_captureparm *cparm = &a->parm.capture;
  1004 +
  1005 + if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1090 1006 return -EINVAL;
1091 1007
1092   - frms->type = V4L2_FRMSIZE_TYPE_DISCRETE;
1093   - frms->discrete.width = mt9p031_sizes[frms->index].width;
1094   - frms->discrete.height = mt9p031_sizes[frms->index].height;
  1008 + memset(a, 0, sizeof(*a));
  1009 + a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
  1010 +
  1011 + cparm->capability = V4L2_CAP_TIMEPERFRAME;
  1012 + cparm->timeperframe.numerator = 1;
  1013 + cparm->timeperframe = priv->timeperframe;
1095 1014
1096 1015 return 0;
  1016 +}
  1017 +
  1018 +/**
  1019 + * mt9p031_v4l2_int_g_priv - V4L2 sensor interface handler for vidioc_int_g_priv_num
  1020 + * @s: pointer to standard V4L2 device structure
  1021 + * @p: void pointer to hold sensor's private data address
  1022 + *
  1023 + * Returns device's (sensor's) private data area address in p parameter
  1024 + */
  1025 +static int mt9p031_v4l2_int_g_priv(struct v4l2_int_device *s, void *p)
  1026 +{
  1027 + struct mt9p031_priv *priv = s->priv;
1097 1028
  1029 + return priv->pdata->priv_data_set(p);
1098 1030 }
1099 1031
1100 1032 /**
1101   - * ioctl_enum_fmt_cap - Implement the CAPTURE buffer VIDIOC_ENUM_FMT ioctl
  1033 + * mt9p031_v4l2_int_g_ifparm - V4L2 sensor interface handler for vidioc_int_g_priv_num
1102 1034 * @s: pointer to standard V4L2 device structure
1103   - * @fmt: standard V4L2 VIDIOC_ENUM_FMT ioctl structure
  1035 + * @p: void pointer to hold sensor's ifparm
1104 1036 *
1105   - * Implement the VIDIOC_ENUM_FMT ioctl for the CAPTURE buffer type.
  1037 + * Returns device's (sensor's) ifparm in p parameter
1106 1038 */
1107   -static int mt9p031_v4l2_int_enum_fmt_cap(struct v4l2_int_device *s,
1108   - struct v4l2_fmtdesc *fmt)
  1039 +static int mt9p031_v4l2_int_g_ifparm(struct v4l2_int_device *s,
  1040 + struct v4l2_ifparm *p)
1109 1041 {
1110   - int index = fmt->index;
1111   - enum v4l2_buf_type type = fmt->type;
  1042 + struct mt9p031_priv *priv = s->priv;
  1043 + int rval;
1112 1044
1113   - memset(fmt, 0, sizeof(*fmt));
1114   - fmt->index = index;
1115   - fmt->type = type;
  1045 + if (p == NULL)
  1046 + return -EINVAL;
1116 1047
1117   - switch (fmt->type) {
1118   - case V4L2_BUF_TYPE_VIDEO_CAPTURE:
1119   - if (index >= ARRAY_SIZE(mt9p031_formats))
1120   - return -EINVAL;
1121   - break;
1122   - default:
  1048 + if (!priv->pdata->ifparm)
1123 1049 return -EINVAL;
1124   - }
1125 1050
1126   - strlcpy(fmt->description, mt9p031_formats[index].description,
1127   - sizeof(fmt->description));
1128   - fmt->pixelformat = mt9p031_formats[index].pixelformat;
  1051 + rval = priv->pdata->ifparm(p);
  1052 + if (rval) {
  1053 + v4l_err(priv->client, "g_ifparm.Err[%d]\n", rval);
  1054 + return rval;
  1055 + }
1129 1056
1130 1057 return 0;
1131 1058 }
1132 1059
1133 1060 /**
1134   - * mt9p031_v4l2_int_g_fmt_cap - V4L2 sensor interface handler for ioctl_g_fmt_cap
  1061 + * mt9p031_v4l2_int_enum_framesizes - V4L2 sensor if handler for vidioc_int_enum_framesizes
1135 1062 * @s: pointer to standard V4L2 device structure
1136   - * @f: pointer to standard V4L2 v4l2_format structure
  1063 + * @frms: pointer to standard V4L2 framesizes enumeration structure
1137 1064 *
1138   - * Returns the sensor's current pixel format in the v4l2_format
1139   - * parameter.
  1065 + * Returns possible framesizes depending on choosen pixel format
1140 1066 */
1141   -static int mt9p031_v4l2_int_g_fmt_cap(struct v4l2_int_device *s,
1142   - struct v4l2_format *f)
  1067 +static int mt9p031_v4l2_int_enum_framesizes(struct v4l2_int_device *s,
  1068 + struct v4l2_frmsizeenum *frms)
1143 1069 {
1144   - struct mt9p031_priv *priv = s->priv;
1145   -
1146   - f->fmt.pix.width = priv->pix.width;
1147   - f->fmt.pix.height = priv->pix.height;
1148   - f->fmt.pix.pixelformat = V4L2_COLORSPACE_SRGB;
1149   - f->fmt.pix.pixelformat = priv->pix.pixelformat;
1150   - f->fmt.pix.field = V4L2_FIELD_NONE;
  1070 + int ifmt;
  1071 +
  1072 + for (ifmt = 0; ifmt < ARRAY_SIZE(mt9p031_formats); ifmt++)
  1073 + if (mt9p031_formats[ifmt].pixelformat == frms->pixel_format)
  1074 + break;
  1075 +
  1076 + if (ifmt == ARRAY_SIZE(mt9p031_formats))
  1077 + return -EINVAL;
  1078 +
  1079 + /* Do we already reached all discrete framesizes? */
  1080 + if (frms->index >= ARRAY_SIZE(mt9p031_sizes))
  1081 + return -EINVAL;
  1082 +
  1083 + frms->type = V4L2_FRMSIZE_TYPE_DISCRETE;
  1084 + frms->discrete.width = mt9p031_sizes[frms->index].width;
  1085 + frms->discrete.height = mt9p031_sizes[frms->index].height;
1151 1086
1152 1087 return 0;
1153 1088 }
@@ -1165,28 +1100,23 @@ static int mt9p031_v4l2_int_enum_frameintervals(struct v4l2_int_device *s,
1165 1100 if (ifmt == ARRAY_SIZE(mt9p031_formats))
1166 1101 return -EINVAL;
1167 1102
1168   - /* Do we already reached all discrete framesizes? */
1169 1103 max_size = ARRAY_SIZE(mt9p031_sizes);
1170   - if (((frmi->width == mt9p031_sizes[max_size-1].width) &&
1171   - (frmi->height == mt9p031_sizes[max_size-1].height)) ||
1172   - ((frmi->width == mt9p031_sizes[max_size-2].width) &&
1173   - (frmi->height == mt9p031_sizes[max_size-2].height))) {
1174   - /* FIXME: The only frameinterval supported by 5MP and 3MP
1175   - * capture sizes is 1/10 fps
1176   - */
1177   - if (frmi->index != 0)
1178   - return -EINVAL;
1179   - } else {
1180   - if (frmi->index >= ARRAY_SIZE(mt9p031_frameintervals))
1181   - return -EINVAL;
1182   - }
1183   -
1184   - frmi->type = V4L2_FRMSIZE_TYPE_DISCRETE;
1185   - frmi->discrete.numerator =
  1104 +
  1105 + for(ifmt = 0; ifmt < max_size; ifmt++) {
  1106 + if(frmi->width <= mt9p031_sizes[ifmt].width) {
  1107 + frmi->type = V4L2_FRMSIZE_TYPE_DISCRETE;
  1108 + frmi->discrete.numerator =
1186 1109 mt9p031_frameintervals[frmi->index].numerator;
1187   - frmi->discrete.denominator =
  1110 + frmi->discrete.denominator =
1188 1111 mt9p031_frameintervals[frmi->index].denominator;
1189   -
  1112 +
  1113 + if(frmi->discrete.denominator <= mt9p031_frameintervals[max_size - ifmt - 1].denominator)
  1114 + return 0;
  1115 + else
  1116 + return -EINVAL;
  1117 + }
  1118 + }
  1119 +
1190 1120 return 0;
1191 1121 }
1192 1122
@@ -1241,7 +1171,7 @@ static ssize_t
1241 1171 mt9p031_basic_reg_addr_store( struct device *dev, struct device_attribute *attr, const char *buf, size_t n)
1242 1172 {
1243 1173 u16 val;
1244   - sscanf(buf, "%x", &val);
  1174 + sscanf(buf, "%x",(unsigned int *) &val);
1245 1175 mt9p031_attr_basic_addr = (u16) val;
1246 1176 return n;
1247 1177 }
@@ -1351,7 +1281,7 @@ mt9p031_gain_val_store( struct device *dev, struct device_attribute *attr, const
1351 1281 struct i2c_client *client;
1352 1282 struct vcontrol *lvc;
1353 1283
1354   - sscanf(buf, "%d", &val);
  1284 + sscanf(buf, "%d", (int *)&val);
1355 1285 client = sysPriv.client;
1356 1286
1357 1287 lvc = &mt9p031_video_control[V4L2_CID_GAIN];
@@ -1441,13 +1371,14 @@ static int mt9p031_probe(struct i2c_client *client,
1441 1371 priv->pdata = client->dev.platform_data;
1442 1372
1443 1373 priv->pdata->flags = MT9P031_FLAG_PCLK_RISING_EDGE;
1444   - i2c_set_clientdata(client, priv);
1445   -
  1374 +
1446 1375 /* Setting Pixel Values */
1447 1376 priv->pix.width = mt9p031_sizes[0].width;
1448 1377 priv->pix.height = mt9p031_sizes[0].height;
1449 1378 priv->pix.pixelformat = mt9p031_formats[0].pixelformat;
1450 1379
  1380 + i2c_set_clientdata(client, priv);
  1381 +
1451 1382 sysPriv.client = priv->client;
1452 1383
1453 1384 ret = v4l2_int_device_register(priv->v4l2_int_device);

0 comments on commit 64fdae2

Please sign in to comment.
Something went wrong with that request. Please try again.