aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@iki.fi>2012-10-20 09:35:25 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-10-29 07:50:29 -0400
commitf5984bbdf402b586581bc292a5449f17ce4b8209 (patch)
treeaa3ef8e90887b8955ca43df9205a5ede55832438 /drivers/media
parent1e9240b35264fa0280abc4487b47b28eecf10b52 (diff)
[media] smiapp-pll: Parallel bus support
Support sensors with parallel interface. Make smiapp_pll.flags also 8-bit so it fits nicely into two 32-bit words with the other 8-bit fields. Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/i2c/smiapp-pll.c19
-rw-r--r--drivers/media/i2c/smiapp-pll.h26
-rw-r--r--drivers/media/i2c/smiapp/smiapp-core.c3
3 files changed, 37 insertions, 11 deletions
diff --git a/drivers/media/i2c/smiapp-pll.c b/drivers/media/i2c/smiapp-pll.c
index d7e347594e19..d3243602c77a 100644
--- a/drivers/media/i2c/smiapp-pll.c
+++ b/drivers/media/i2c/smiapp-pll.c
@@ -371,7 +371,7 @@ int smiapp_pll_calculate(struct device *dev, struct smiapp_pll_limits *limits,
371 int rval = -EINVAL; 371 int rval = -EINVAL;
372 372
373 if (pll->flags & SMIAPP_PLL_FLAG_OP_PIX_CLOCK_PER_LANE) 373 if (pll->flags & SMIAPP_PLL_FLAG_OP_PIX_CLOCK_PER_LANE)
374 lane_op_clock_ratio = pll->lanes; 374 lane_op_clock_ratio = pll->csi2.lanes;
375 else 375 else
376 lane_op_clock_ratio = 1; 376 lane_op_clock_ratio = 1;
377 dev_dbg(dev, "lane_op_clock_ratio: %d\n", lane_op_clock_ratio); 377 dev_dbg(dev, "lane_op_clock_ratio: %d\n", lane_op_clock_ratio);
@@ -379,9 +379,20 @@ int smiapp_pll_calculate(struct device *dev, struct smiapp_pll_limits *limits,
379 dev_dbg(dev, "binning: %dx%d\n", pll->binning_horizontal, 379 dev_dbg(dev, "binning: %dx%d\n", pll->binning_horizontal,
380 pll->binning_vertical); 380 pll->binning_vertical);
381 381
382 /* CSI transfers 2 bits per clock per lane; thus times 2 */ 382 switch (pll->bus_type) {
383 pll->pll_op_clk_freq_hz = pll->link_freq * 2 383 case SMIAPP_PLL_BUS_TYPE_CSI2:
384 * (pll->lanes / lane_op_clock_ratio); 384 /* CSI transfers 2 bits per clock per lane; thus times 2 */
385 pll->pll_op_clk_freq_hz = pll->link_freq * 2
386 * (pll->csi2.lanes / lane_op_clock_ratio);
387 break;
388 case SMIAPP_PLL_BUS_TYPE_PARALLEL:
389 pll->pll_op_clk_freq_hz = pll->link_freq * pll->bits_per_pixel
390 / DIV_ROUND_UP(pll->bits_per_pixel,
391 pll->parallel.bus_width);
392 break;
393 default:
394 return -EINVAL;
395 }
385 396
386 /* Figure out limits for pre-pll divider based on extclk */ 397 /* Figure out limits for pre-pll divider based on extclk */
387 dev_dbg(dev, "min / max pre_pll_clk_div: %d / %d\n", 398 dev_dbg(dev, "min / max pre_pll_clk_div: %d / %d\n",
diff --git a/drivers/media/i2c/smiapp-pll.h b/drivers/media/i2c/smiapp-pll.h
index cb2d2db5d02d..439fe5d665b0 100644
--- a/drivers/media/i2c/smiapp-pll.h
+++ b/drivers/media/i2c/smiapp-pll.h
@@ -27,16 +27,34 @@
27 27
28#include <linux/device.h> 28#include <linux/device.h>
29 29
30/* CSI-2 or CCP-2 */
31#define SMIAPP_PLL_BUS_TYPE_CSI2 0x00
32#define SMIAPP_PLL_BUS_TYPE_PARALLEL 0x01
33
34/* op pix clock is for all lanes in total normally */
35#define SMIAPP_PLL_FLAG_OP_PIX_CLOCK_PER_LANE (1 << 0)
36#define SMIAPP_PLL_FLAG_NO_OP_CLOCKS (1 << 1)
37
30struct smiapp_pll { 38struct smiapp_pll {
31 uint8_t lanes; 39 /* input values */
40 uint8_t bus_type;
41 union {
42 struct {
43 uint8_t lanes;
44 } csi2;
45 struct {
46 uint8_t bus_width;
47 } parallel;
48 };
49 uint8_t flags;
32 uint8_t binning_horizontal; 50 uint8_t binning_horizontal;
33 uint8_t binning_vertical; 51 uint8_t binning_vertical;
34 uint8_t scale_m; 52 uint8_t scale_m;
35 uint8_t scale_n; 53 uint8_t scale_n;
36 uint8_t bits_per_pixel; 54 uint8_t bits_per_pixel;
37 uint16_t flags;
38 uint32_t link_freq; 55 uint32_t link_freq;
39 56
57 /* output values */
40 uint16_t pre_pll_clk_div; 58 uint16_t pre_pll_clk_div;
41 uint16_t pll_multiplier; 59 uint16_t pll_multiplier;
42 uint16_t op_sys_clk_div; 60 uint16_t op_sys_clk_div;
@@ -91,10 +109,6 @@ struct smiapp_pll_limits {
91 uint32_t min_line_length_pck; 109 uint32_t min_line_length_pck;
92}; 110};
93 111
94/* op pix clock is for all lanes in total normally */
95#define SMIAPP_PLL_FLAG_OP_PIX_CLOCK_PER_LANE (1 << 0)
96#define SMIAPP_PLL_FLAG_NO_OP_CLOCKS (1 << 1)
97
98struct device; 112struct device;
99 113
100int smiapp_pll_calculate(struct device *dev, struct smiapp_pll_limits *limits, 114int smiapp_pll_calculate(struct device *dev, struct smiapp_pll_limits *limits,
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index 868ad0ba59b6..42316cb57041 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -2625,7 +2625,8 @@ static int smiapp_registered(struct v4l2_subdev *subdev)
2625 goto out_nvm_release; 2625 goto out_nvm_release;
2626 2626
2627 /* prepare PLL configuration input values */ 2627 /* prepare PLL configuration input values */
2628 pll->lanes = sensor->platform_data->lanes; 2628 pll->bus_type = SMIAPP_PLL_BUS_TYPE_CSI2;
2629 pll->csi2.lanes = sensor->platform_data->lanes;
2629 pll->ext_clk_freq_hz = sensor->platform_data->ext_clk; 2630 pll->ext_clk_freq_hz = sensor->platform_data->ext_clk;
2630 /* Profile 0 sensors have no separate OP clock branch. */ 2631 /* Profile 0 sensors have no separate OP clock branch. */
2631 if (sensor->minfo.smiapp_profile == SMIAPP_PROFILE_0) 2632 if (sensor->minfo.smiapp_profile == SMIAPP_PROFILE_0)