Skip to content

Commit

Permalink
media: camss: Add 8x96 resources
Browse files Browse the repository at this point in the history
Add structs with 8x96 resources. As the number of CSIPHY, CSID
and VFE hardware modules is different on 8x16 and 8x96 select
the number at runtime and allocate needed structures
dynamically.

Signed-off-by: Todor Tomov <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
todortomov authored and mchehab committed Aug 2, 2018
1 parent 21a3f6e commit 9c3e59d
Show file tree
Hide file tree
Showing 10 changed files with 390 additions and 139 deletions.
20 changes: 11 additions & 9 deletions drivers/media/platform/qcom/camss/camss-csid.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ static irqreturn_t csid_isr(int irq, void *dev)
*/
static int csid_set_clock_rates(struct csid_device *csid)
{
struct device *dev = to_device_index(csid, csid->id);
struct device *dev = csid->camss->dev;
u32 pixel_clock;
int i, j;
int ret;
Expand All @@ -232,7 +232,9 @@ static int csid_set_clock_rates(struct csid_device *csid)
struct camss_clock *clock = &csid->clock[i];

if (!strcmp(clock->name, "csi0") ||
!strcmp(clock->name, "csi1")) {
!strcmp(clock->name, "csi1") ||
!strcmp(clock->name, "csi2") ||
!strcmp(clock->name, "csi3")) {
u8 bpp = csid_get_fmt_entry(
csid->fmt[MSM_CSIPHY_PAD_SINK].code)->bpp;
u8 num_lanes = csid->phy.lane_cnt;
Expand Down Expand Up @@ -291,8 +293,7 @@ static int csid_reset(struct csid_device *csid)
time = wait_for_completion_timeout(&csid->reset_complete,
msecs_to_jiffies(CSID_RESET_TIMEOUT_MS));
if (!time) {
dev_err(to_device_index(csid, csid->id),
"CSID reset timeout\n");
dev_err(csid->camss->dev, "CSID reset timeout\n");
return -EIO;
}

Expand All @@ -309,7 +310,7 @@ static int csid_reset(struct csid_device *csid)
static int csid_set_power(struct v4l2_subdev *sd, int on)
{
struct csid_device *csid = v4l2_get_subdevdata(sd);
struct device *dev = to_device_index(csid, csid->id);
struct device *dev = csid->camss->dev;
int ret;

if (on) {
Expand Down Expand Up @@ -375,7 +376,7 @@ static int csid_set_stream(struct v4l2_subdev *sd, int enable)

ret = v4l2_ctrl_handler_setup(&csid->ctrls);
if (ret < 0) {
dev_err(to_device_index(csid, csid->id),
dev_err(csid->camss->dev,
"could not sync v4l2 controls: %d\n", ret);
return ret;
}
Expand Down Expand Up @@ -796,15 +797,16 @@ static const struct v4l2_ctrl_ops csid_ctrl_ops = {
*
* Return 0 on success or a negative error code otherwise
*/
int msm_csid_subdev_init(struct csid_device *csid,
int msm_csid_subdev_init(struct camss *camss, struct csid_device *csid,
const struct resources *res, u8 id)
{
struct device *dev = to_device_index(csid, id);
struct device *dev = camss->dev;
struct platform_device *pdev = to_platform_device(dev);
struct resource *r;
int i, j;
int ret;

csid->camss = camss;
csid->id = id;

/* Memory */
Expand Down Expand Up @@ -1018,7 +1020,7 @@ int msm_csid_register_entity(struct csid_device *csid,
{
struct v4l2_subdev *sd = &csid->subdev;
struct media_pad *pads = csid->pads;
struct device *dev = to_device_index(csid, csid->id);
struct device *dev = csid->camss->dev;
int ret;

v4l2_subdev_init(sd, &csid_v4l2_ops);
Expand Down
3 changes: 2 additions & 1 deletion drivers/media/platform/qcom/camss/camss-csid.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ struct csid_phy_config {
};

struct csid_device {
struct camss *camss;
u8 id;
struct v4l2_subdev subdev;
struct media_pad pads[MSM_CSID_PADS_NUM];
Expand All @@ -61,7 +62,7 @@ struct csid_device {

struct resources;

int msm_csid_subdev_init(struct csid_device *csid,
int msm_csid_subdev_init(struct camss *camss, struct csid_device *csid,
const struct resources *res, u8 id);

int msm_csid_register_entity(struct csid_device *csid,
Expand Down
19 changes: 11 additions & 8 deletions drivers/media/platform/qcom/camss/camss-csiphy.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ static irqreturn_t csiphy_isr(int irq, void *dev)
*/
static int csiphy_set_clock_rates(struct csiphy_device *csiphy)
{
struct device *dev = to_device_index(csiphy, csiphy->id);
struct device *dev = csiphy->camss->dev;
u32 pixel_clock;
int i, j;
int ret;
Expand All @@ -168,7 +168,8 @@ static int csiphy_set_clock_rates(struct csiphy_device *csiphy)
struct camss_clock *clock = &csiphy->clock[i];

if (!strcmp(clock->name, "csiphy0_timer") ||
!strcmp(clock->name, "csiphy1_timer")) {
!strcmp(clock->name, "csiphy1_timer") ||
!strcmp(clock->name, "csiphy2_timer")) {
u8 bpp = csiphy_get_bpp(
csiphy->fmt[MSM_CSIPHY_PAD_SINK].code);
u8 num_lanes = csiphy->cfg.csi2->lane_cfg.num_data;
Expand Down Expand Up @@ -233,7 +234,7 @@ static void csiphy_reset(struct csiphy_device *csiphy)
static int csiphy_set_power(struct v4l2_subdev *sd, int on)
{
struct csiphy_device *csiphy = v4l2_get_subdevdata(sd);
struct device *dev = to_device_index(csiphy, csiphy->id);
struct device *dev = csiphy->camss->dev;

if (on) {
u8 hw_version;
Expand Down Expand Up @@ -311,12 +312,12 @@ static u8 csiphy_settle_cnt_calc(struct csiphy_device *csiphy)

ret = camss_get_pixel_clock(&csiphy->subdev.entity, &pixel_clock);
if (ret) {
dev_err(to_device_index(csiphy, csiphy->id),
dev_err(csiphy->camss->dev,
"Cannot get CSI2 transmitter's pixel clock\n");
return 0;
}
if (!pixel_clock) {
dev_err(to_device_index(csiphy, csiphy->id),
dev_err(csiphy->camss->dev,
"Got pixel clock == 0, cannot continue\n");
return 0;
}
Expand Down Expand Up @@ -670,15 +671,17 @@ static int csiphy_init_formats(struct v4l2_subdev *sd,
*
* Return 0 on success or a negative error code otherwise
*/
int msm_csiphy_subdev_init(struct csiphy_device *csiphy,
int msm_csiphy_subdev_init(struct camss *camss,
struct csiphy_device *csiphy,
const struct resources *res, u8 id)
{
struct device *dev = to_device_index(csiphy, id);
struct device *dev = camss->dev;
struct platform_device *pdev = to_platform_device(dev);
struct resource *r;
int i, j;
int ret;

csiphy->camss = camss;
csiphy->id = id;
csiphy->cfg.combo_mode = 0;

Expand Down Expand Up @@ -839,7 +842,7 @@ int msm_csiphy_register_entity(struct csiphy_device *csiphy,
{
struct v4l2_subdev *sd = &csiphy->subdev;
struct media_pad *pads = csiphy->pads;
struct device *dev = to_device_index(csiphy, csiphy->id);
struct device *dev = csiphy->camss->dev;
int ret;

v4l2_subdev_init(sd, &csiphy_v4l2_ops);
Expand Down
4 changes: 3 additions & 1 deletion drivers/media/platform/qcom/camss/camss-csiphy.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ struct csiphy_config {
};

struct csiphy_device {
struct camss *camss;
u8 id;
struct v4l2_subdev subdev;
struct media_pad pads[MSM_CSIPHY_PADS_NUM];
Expand All @@ -58,7 +59,8 @@ struct csiphy_device {

struct resources;

int msm_csiphy_subdev_init(struct csiphy_device *csiphy,
int msm_csiphy_subdev_init(struct camss *camss,
struct csiphy_device *csiphy,
const struct resources *res, u8 id);

int msm_csiphy_register_entity(struct csiphy_device *csiphy,
Expand Down
35 changes: 22 additions & 13 deletions drivers/media/platform/qcom/camss/camss-ispif.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@

#define MSM_ISPIF_NAME "msm_ispif"

#define ispif_line_array(ptr_line) \
((const struct ispif_line (*)[]) &(ptr_line[-(ptr_line->id)]))

#define to_ispif(ptr_line) \
container_of(ispif_line_array(ptr_line), struct ispif_device, ptr_line)

#define ISPIF_RST_CMD_0 0x008
#define ISPIF_RST_CMD_0_STROBED_RST_EN (1 << 0)
#define ISPIF_RST_CMD_0_MISC_LOGIC_RST (1 << 1)
Expand Down Expand Up @@ -225,7 +219,7 @@ static int ispif_reset(struct ispif_device *ispif)
static int ispif_set_power(struct v4l2_subdev *sd, int on)
{
struct ispif_line *line = v4l2_get_subdevdata(sd);
struct ispif_device *ispif = to_ispif(line);
struct ispif_device *ispif = line->ispif;
struct device *dev = to_device(ispif);
int ret = 0;

Expand Down Expand Up @@ -611,7 +605,7 @@ static void ispif_set_intf_cmd(struct ispif_device *ispif, u8 cmd,
static int ispif_set_stream(struct v4l2_subdev *sd, int enable)
{
struct ispif_line *line = v4l2_get_subdevdata(sd);
struct ispif_device *ispif = to_ispif(line);
struct ispif_device *ispif = line->ispif;
enum ispif_intf intf = line->interface;
u8 csid = line->csid_id;
u8 vfe = line->vfe_id;
Expand Down Expand Up @@ -899,6 +893,24 @@ int msm_ispif_subdev_init(struct ispif_device *ispif,
int i;
int ret;

/* Number of ISPIF lines - same as number of CSID hardware modules */
if (to_camss(ispif)->version == CAMSS_8x16)
ispif->line_num = 2;
else if (to_camss(ispif)->version == CAMSS_8x96)
ispif->line_num = 4;
else
return -EINVAL;

ispif->line = kcalloc(ispif->line_num, sizeof(*ispif->line),
GFP_KERNEL);
if (!ispif->line)
return -ENOMEM;

for (i = 0; i < ispif->line_num; i++) {
ispif->line[i].ispif = ispif;
ispif->line[i].id = i;
}

/* Memory */

r = platform_get_resource_byname(pdev, IORESOURCE_MEM, res->reg[0]);
Expand Down Expand Up @@ -979,9 +991,6 @@ int msm_ispif_subdev_init(struct ispif_device *ispif,
clock->nfreqs = 0;
}

for (i = 0; i < ARRAY_SIZE(ispif->line); i++)
ispif->line[i].id = i;

mutex_init(&ispif->power_lock);
ispif->power_count = 0;

Expand Down Expand Up @@ -1100,7 +1109,7 @@ int msm_ispif_register_entities(struct ispif_device *ispif,
int ret;
int i;

for (i = 0; i < ARRAY_SIZE(ispif->line); i++) {
for (i = 0; i < ispif->line_num; i++) {
struct v4l2_subdev *sd = &ispif->line[i].subdev;
struct media_pad *pads = ispif->line[i].pads;

Expand Down Expand Up @@ -1161,7 +1170,7 @@ void msm_ispif_unregister_entities(struct ispif_device *ispif)
mutex_destroy(&ispif->power_lock);
mutex_destroy(&ispif->config_lock);

for (i = 0; i < ARRAY_SIZE(ispif->line); i++) {
for (i = 0; i < ispif->line_num; i++) {
struct v4l2_subdev *sd = &ispif->line[i].subdev;

v4l2_device_unregister_subdev(sd);
Expand Down
9 changes: 4 additions & 5 deletions drivers/media/platform/qcom/camss/camss-ispif.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@
#include <media/v4l2-device.h>
#include <media/v4l2-subdev.h>

/* Number of ISPIF lines - same as number of CSID hardware modules */
#define MSM_ISPIF_LINE_NUM 2

#define MSM_ISPIF_PAD_SINK 0
#define MSM_ISPIF_PAD_SRC 1
#define MSM_ISPIF_PADS_NUM 2

#define MSM_ISPIF_VFE_NUM 1
#define MSM_ISPIF_VFE_NUM 2

enum ispif_intf {
PIX0,
Expand All @@ -38,6 +35,7 @@ struct ispif_intf_cmd_reg {
};

struct ispif_line {
struct ispif_device *ispif;
u8 id;
u8 csid_id;
u8 vfe_id;
Expand All @@ -61,7 +59,8 @@ struct ispif_device {
struct mutex power_lock;
struct ispif_intf_cmd_reg intf_cmd[MSM_ISPIF_VFE_NUM];
struct mutex config_lock;
struct ispif_line line[MSM_ISPIF_LINE_NUM];
unsigned int line_num;
struct ispif_line *line;
};

struct resources_ispif;
Expand Down
Loading

0 comments on commit 9c3e59d

Please sign in to comment.