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

ARM: mach-shmobile: ag5evm: Use the backlight API for brightness control

Don't hook up brightness control in the display on/off operations, use
the backlight API instead.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Simon Horman <horms@verge.net.au>

+29 -16
+29 -16
arch/arm/mach-shmobile/board-ag5evm.c
··· 295 295 { 0x03, 0x01 }, 296 296 }; 297 297 298 - static void lcd_backlight_on(void) 298 + static int lcd_backlight_set_brightness(int brightness) 299 299 { 300 - struct i2c_adapter *a; 300 + struct i2c_adapter *adap; 301 301 struct i2c_msg msg; 302 - int k; 302 + unsigned int i; 303 + int ret; 303 304 304 - a = i2c_get_adapter(1); 305 - for (k = 0; a && k < 3; k++) { 305 + if (brightness == 0) { 306 + /* Reset the chip */ 307 + gpio_set_value(GPIO_PORT235, 0); 308 + mdelay(24); 309 + gpio_set_value(GPIO_PORT235, 1); 310 + return 0; 311 + } 312 + 313 + adap = i2c_get_adapter(1); 314 + if (adap == NULL) 315 + return -ENODEV; 316 + 317 + for (i = 0; i < ARRAY_SIZE(lcd_backlight_seq); i++) { 306 318 msg.addr = 0x6d; 307 - msg.buf = &lcd_backlight_seq[k][0]; 319 + msg.buf = &lcd_backlight_seq[i][0]; 308 320 msg.len = 2; 309 321 msg.flags = 0; 310 - if (i2c_transfer(a, &msg, 1) != 1) 322 + 323 + ret = i2c_transfer(adap, &msg, 1); 324 + if (ret < 0) 311 325 break; 312 326 } 313 - } 314 327 315 - static void lcd_backlight_reset(void) 316 - { 317 - gpio_set_value(GPIO_PORT235, 0); 318 - mdelay(24); 319 - gpio_set_value(GPIO_PORT235, 1); 328 + i2c_put_adapter(adap); 329 + return ret < 0 ? ret : 0; 320 330 } 321 331 322 332 /* LCDC0 */ ··· 358 348 .panel_cfg = { 359 349 .width = 44, 360 350 .height = 79, 361 - .display_on = lcd_backlight_on, 362 - .display_off = lcd_backlight_reset, 351 + }, 352 + .bl_info = { 353 + .name = "sh_mobile_lcdc_bl", 354 + .max_brightness = 1, 355 + .set_brightness = lcd_backlight_set_brightness, 363 356 }, 364 357 .tx_dev = &mipidsi0_device, 365 358 } ··· 635 622 /* LCD backlight controller */ 636 623 gpio_request(GPIO_PORT235, NULL); /* RESET */ 637 624 gpio_direction_output(GPIO_PORT235, 0); 638 - lcd_backlight_reset(); 625 + lcd_backlight_set_brightness(0); 639 626 640 627 /* enable SDHI0 on CN15 [SD I/F] */ 641 628 gpio_request(GPIO_FN_SDHIWP0, NULL);