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

Configure Feed

Select the types of activity you want to include in your feed.

media: ar0521: Rework startup sequence

The ar0521_write_mode() function explicitly programs the exposure time
register and the test pattern register, which are now setup by the call
to __v4l2_ctrl_handler_setup() in ar0521_set_stream().

Removing those register writes from ar0521_write_mode() reduces the
function to two operations: geometry configuration and pll
configuration.

Move geomerty configuration in the ar0521_set_stream() caller and rename
ar0521_write_mode() to ar0521_pll_config().

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>

authored by

Jacopo Mondi and committed by
Mauro Carvalho Chehab
e0b8d21b c79f0f15

+16 -34
+16 -34
drivers/media/i2c/ar0521.c
··· 278 278 return pll; 279 279 } 280 280 281 - static void ar0521_calc_mode(struct ar0521_dev *sensor) 281 + static void ar0521_calc_pll(struct ar0521_dev *sensor) 282 282 { 283 283 unsigned int pixel_clock; 284 284 u16 pre, mult; ··· 342 342 sensor->pll.mult = sensor->pll.mult2 = mult; 343 343 } 344 344 345 - static int ar0521_write_mode(struct ar0521_dev *sensor) 345 + static int ar0521_pll_config(struct ar0521_dev *sensor) 346 346 { 347 347 __be16 pll_regs[] = { 348 348 be(AR0521_REG_VT_PIX_CLK_DIV), ··· 353 353 /* 0x308 */ be(sensor->pll.vt_pix * 2), /* op_pix_clk_div = 2 * vt_pix_clk_div */ 354 354 /* 0x30A */ be(1) /* op_sys_clk_div */ 355 355 }; 356 - int ret; 357 356 358 - /* Stop streaming for just a moment */ 359 - ret = ar0521_write_reg(sensor, AR0521_REG_RESET, 360 - AR0521_REG_RESET_DEFAULTS); 361 - if (ret) 362 - return ret; 363 - 364 - ret = ar0521_set_geometry(sensor); 365 - if (ret) 366 - return ret; 367 - 368 - ret = ar0521_write_regs(sensor, pll_regs, ARRAY_SIZE(pll_regs)); 369 - if (ret) 370 - return ret; 371 - 372 - ret = ar0521_write_reg(sensor, AR0521_REG_COARSE_INTEGRATION_TIME, 373 - sensor->ctrls.exposure->val); 374 - if (ret) 375 - return ret; 376 - 377 - ret = ar0521_write_reg(sensor, AR0521_REG_RESET, 378 - AR0521_REG_RESET_DEFAULTS | 379 - AR0521_REG_RESET_STREAM); 380 - if (ret) 381 - return ret; 382 - 383 - ret = ar0521_write_reg(sensor, AR0521_REG_TEST_PATTERN_MODE, 384 - sensor->ctrls.test_pattern->val); 385 - return ret; 357 + ar0521_calc_pll(sensor); 358 + return ar0521_write_regs(sensor, pll_regs, ARRAY_SIZE(pll_regs)); 386 359 } 387 360 388 361 static int ar0521_set_stream(struct ar0521_dev *sensor, bool on) ··· 367 394 if (ret < 0) 368 395 return ret; 369 396 370 - ar0521_calc_mode(sensor); 371 - ret = ar0521_write_mode(sensor); 397 + /* Stop streaming for just a moment */ 398 + ret = ar0521_write_reg(sensor, AR0521_REG_RESET, 399 + AR0521_REG_RESET_DEFAULTS); 400 + if (ret) 401 + return ret; 402 + 403 + ret = ar0521_set_geometry(sensor); 404 + if (ret) 405 + return ret; 406 + 407 + ret = ar0521_pll_config(sensor); 372 408 if (ret) 373 409 goto err; 374 410 ··· 483 501 } 484 502 485 503 sensor->fmt = format->format; 486 - ar0521_calc_mode(sensor); 504 + ar0521_calc_pll(sensor); 487 505 488 506 /* 489 507 * Update the exposure and blankings limits. Blankings are also reset