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

fbdev: sh_mobile_lcdc: Remove sh_mobile_lcdc_set_bpp()

The function duplicates code found in sh_mobile_check_var(). Remove
sh_mobile_lcdc_set_bpp() and call sh_mobile_check_var() instead.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>

authored by

Laurent Pinchart and committed by
Florian Tobias Schandinat
a67472ad 3ce05599

+17 -70
+17 -70
drivers/video/sh_mobile_lcdcfb.c
··· 1291 1291 backlight_device_unregister(bdev); 1292 1292 } 1293 1293 1294 - static int sh_mobile_lcdc_set_bpp(struct fb_var_screeninfo *var, int bpp, 1295 - int nonstd) 1296 - { 1297 - if (nonstd) { 1298 - switch (bpp) { 1299 - case 12: 1300 - case 16: 1301 - case 24: 1302 - var->bits_per_pixel = bpp; 1303 - var->nonstd = nonstd; 1304 - return 0; 1305 - default: 1306 - return -EINVAL; 1307 - } 1308 - } 1309 - 1310 - switch (bpp) { 1311 - case 16: /* PKF[4:0] = 00011 - RGB 565 */ 1312 - var->red.offset = 11; 1313 - var->red.length = 5; 1314 - var->green.offset = 5; 1315 - var->green.length = 6; 1316 - var->blue.offset = 0; 1317 - var->blue.length = 5; 1318 - var->transp.offset = 0; 1319 - var->transp.length = 0; 1320 - break; 1321 - 1322 - case 24: /* PKF[4:0] = 01011 - RGB 888 */ 1323 - var->red.offset = 16; 1324 - var->red.length = 8; 1325 - var->green.offset = 8; 1326 - var->green.length = 8; 1327 - var->blue.offset = 0; 1328 - var->blue.length = 8; 1329 - var->transp.offset = 0; 1330 - var->transp.length = 0; 1331 - break; 1332 - 1333 - case 32: /* PKF[4:0] = 00000 - RGBA 888 */ 1334 - var->red.offset = 16; 1335 - var->red.length = 8; 1336 - var->green.offset = 8; 1337 - var->green.length = 8; 1338 - var->blue.offset = 0; 1339 - var->blue.length = 8; 1340 - var->transp.offset = 24; 1341 - var->transp.length = 8; 1342 - break; 1343 - default: 1344 - return -EINVAL; 1345 - } 1346 - var->bits_per_pixel = bpp; 1347 - var->red.msb_right = 0; 1348 - var->green.msb_right = 0; 1349 - var->blue.msb_right = 0; 1350 - var->transp.msb_right = 0; 1351 - return 0; 1352 - } 1353 - 1354 1294 static int sh_mobile_lcdc_suspend(struct device *dev) 1355 1295 { 1356 1296 struct platform_device *pdev = to_platform_device(dev); ··· 1439 1499 int ret; 1440 1500 int i; 1441 1501 1502 + mutex_init(&ch->open_lock); 1503 + 1504 + /* Allocate the frame buffer device. */ 1442 1505 ch->info = framebuffer_alloc(0, dev); 1443 1506 if (!ch->info) { 1444 1507 dev_err(dev, "unable to allocate fb_info\n"); ··· 1449 1506 } 1450 1507 1451 1508 info = ch->info; 1452 - var = &info->var; 1453 1509 info->fbops = &sh_mobile_lcdc_ops; 1454 1510 info->par = ch; 1455 - 1456 - mutex_init(&ch->open_lock); 1511 + info->pseudo_palette = &ch->pseudo_palette; 1512 + info->flags = FBINFO_FLAG_DEFAULT; 1457 1513 1458 1514 /* Iterate through the modes to validate them and find the highest 1459 1515 * resolution. ··· 1483 1541 dev_dbg(dev, "Found largest videomode %ux%u\n", 1484 1542 max_mode->xres, max_mode->yres); 1485 1543 1544 + /* Initialize fixed screen information. Restrict pan to 2 lines steps 1545 + * for NV12. 1546 + */ 1486 1547 info->fix = sh_mobile_lcdc_fix; 1487 1548 info->fix.smem_len = max_size * 2 * cfg->bpp / 8; 1488 - 1489 - /* Only pan in 2 line steps for NV12 */ 1490 1549 if (cfg->nonstd && cfg->bpp == 12) 1491 1550 info->fix.ypanstep = 2; 1492 1551 1552 + /* Create the mode list. */ 1493 1553 if (cfg->lcd_cfg == NULL) { 1494 1554 mode = &default_720p; 1495 1555 num_cfg = 1; ··· 1502 1558 1503 1559 fb_videomode_to_modelist(mode, num_cfg, &info->modelist); 1504 1560 1561 + /* Initialize variable screen information using the first mode as 1562 + * default. The default Y virtual resolution is twice the panel size to 1563 + * allow for double-buffering. 1564 + */ 1565 + var = &info->var; 1505 1566 fb_videomode_to_var(var, mode); 1567 + var->bits_per_pixel = cfg->bpp; 1506 1568 var->width = cfg->lcd_size_cfg.width; 1507 1569 var->height = cfg->lcd_size_cfg.height; 1508 - /* Default Y virtual resolution is 2x panel size */ 1509 1570 var->yres_virtual = var->yres * 2; 1510 1571 var->activate = FB_ACTIVATE_NOW; 1511 1572 1512 - ret = sh_mobile_lcdc_set_bpp(var, cfg->bpp, cfg->nonstd); 1573 + ret = sh_mobile_check_var(var, info); 1513 1574 if (ret) 1514 1575 return ret; 1515 1576 1577 + /* Allocate frame buffer memory and color map. */ 1516 1578 buf = dma_alloc_coherent(dev, info->fix.smem_len, &ch->dma_handle, 1517 1579 GFP_KERNEL); 1518 1580 if (!buf) { 1519 1581 dev_err(dev, "unable to allocate buffer\n"); 1520 1582 return -ENOMEM; 1521 1583 } 1522 - 1523 - info->pseudo_palette = &ch->pseudo_palette; 1524 - info->flags = FBINFO_FLAG_DEFAULT; 1525 1584 1526 1585 ret = fb_alloc_cmap(&info->cmap, PALETTE_NR, 0); 1527 1586 if (ret < 0) {