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

[media] s5p-fimc: Allow defining number of sensors at runtime

Add num_clients field to struct s5p_fimc_isp_info to define exactly
size of clients array which simplifies a bit the sensors management.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Sylwester Nawrocki and committed by
Mauro Carvalho Chehab
117182d1 4ecbf5d1

+21 -31
+10 -13
drivers/media/video/s5p-fimc/fimc-capture.c
··· 91 91 struct v4l2_subdev *sd; 92 92 int i; 93 93 94 - for (i = 0; i < FIMC_MAX_CAMIF_CLIENTS; ++i) { 95 - isp_info = pdata->isp_info[i]; 94 + for (i = 0; i < pdata->num_clients; ++i) { 95 + isp_info = &pdata->isp_info[i]; 96 96 97 - if (!isp_info || (index >= 0 && i != index)) 97 + if (index >= 0 && i != index) 98 98 continue; 99 99 100 100 sd = fimc_subdev_register(fimc, isp_info); ··· 116 116 static int fimc_isp_subdev_init(struct fimc_dev *fimc, unsigned int index) 117 117 { 118 118 struct s5p_fimc_isp_info *isp_info; 119 + struct s5p_platform_fimc *pdata = fimc->pdata; 119 120 int ret; 120 121 121 - if (index >= FIMC_MAX_CAMIF_CLIENTS) 122 + if (index >= pdata->num_clients) 122 123 return -EINVAL; 123 124 124 - isp_info = fimc->pdata->isp_info[index]; 125 - if (!isp_info) 126 - return -EINVAL; 125 + isp_info = &pdata->isp_info[index]; 127 126 128 127 if (isp_info->clk_frequency) 129 128 clk_set_rate(fimc->clock[CLK_CAM], isp_info->clk_frequency); ··· 214 215 if (ret) 215 216 return ret; 216 217 217 - isp_info = fimc->pdata->isp_info[fimc->vid_cap.input_index]; 218 + isp_info = &fimc->pdata->isp_info[fimc->vid_cap.input_index]; 218 219 fimc_hw_set_camera_type(fimc, isp_info); 219 220 fimc_hw_set_camera_source(fimc, isp_info); 220 221 fimc_hw_set_camera_offset(fimc, &ctx->s_frame); ··· 566 567 struct s5p_platform_fimc *pldata = ctx->fimc_dev->pdata; 567 568 struct s5p_fimc_isp_info *isp_info; 568 569 569 - if (i->index >= FIMC_MAX_CAMIF_CLIENTS) 570 + if (i->index >= pldata->num_clients) 570 571 return -EINVAL; 571 572 572 - isp_info = pldata->isp_info[i->index]; 573 - if (isp_info == NULL) 574 - return -EINVAL; 573 + isp_info = &pldata->isp_info[i->index]; 575 574 576 575 i->type = V4L2_INPUT_TYPE_CAMERA; 577 576 strncpy(i->name, isp_info->board_info->type, 32); ··· 586 589 if (fimc_capture_active(ctx->fimc_dev)) 587 590 return -EBUSY; 588 591 589 - if (i >= FIMC_MAX_CAMIF_CLIENTS || !pdata->isp_info[i]) 592 + if (i >= pdata->num_clients) 590 593 return -EINVAL; 591 594 592 595
+8 -14
drivers/media/video/s5p-fimc/fimc-core.c
··· 1577 1577 struct fimc_dev *fimc; 1578 1578 struct resource *res; 1579 1579 struct samsung_fimc_driverdata *drv_data; 1580 + struct s5p_platform_fimc *pdata; 1580 1581 int ret = 0; 1581 1582 int cap_input_index = -1; 1582 1583 ··· 1599 1598 fimc->id = pdev->id; 1600 1599 fimc->variant = drv_data->variant[fimc->id]; 1601 1600 fimc->pdev = pdev; 1602 - fimc->pdata = pdev->dev.platform_data; 1601 + pdata = pdev->dev.platform_data; 1602 + fimc->pdata = pdata; 1603 1603 fimc->state = ST_IDLE; 1604 1604 1605 1605 init_waitqueue_head(&fimc->irq_queue); ··· 1631 1629 } 1632 1630 1633 1631 fimc->num_clocks = MAX_FIMC_CLOCKS - 1; 1634 - /* 1635 - * Check if vide capture node needs to be registered for this device 1636 - * instance. 1637 - */ 1638 - if (fimc->pdata) { 1639 - int i; 1640 - for (i = 0; i < FIMC_MAX_CAMIF_CLIENTS; ++i) 1641 - if (fimc->pdata->isp_info[i]) 1642 - break; 1643 - if (i < FIMC_MAX_CAMIF_CLIENTS) { 1644 - cap_input_index = i; 1645 - fimc->num_clocks++; 1646 - } 1632 + 1633 + /* Check if a video capture node needs to be registered. */ 1634 + if (pdata && pdata->num_clients > 0) { 1635 + cap_input_index = 0; 1636 + fimc->num_clocks++; 1647 1637 } 1648 1638 1649 1639 ret = fimc_clk_get(fimc);
+3 -4
include/media/s5p_fimc.h
··· 46 46 u16 flags; 47 47 }; 48 48 49 - 50 - #define FIMC_MAX_CAMIF_CLIENTS 2 51 - 52 49 /** 53 50 * struct s5p_platform_fimc - camera host interface platform data 54 51 * 55 52 * @isp_info: properties of camera sensor required for host interface setup 53 + * @num_clients: the number of attached image sensors 56 54 */ 57 55 struct s5p_platform_fimc { 58 - struct s5p_fimc_isp_info *isp_info[FIMC_MAX_CAMIF_CLIENTS]; 56 + struct s5p_fimc_isp_info *isp_info; 57 + int num_clients; 59 58 }; 60 59 #endif /* S5P_FIMC_H_ */