Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9c3e59de authored by Todor Tomov's avatar Todor Tomov Committed by Mauro Carvalho Chehab
Browse files

media: camss: Add 8x96 resources



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: default avatarTodor Tomov <todor.tomov@linaro.org>
Signed-off-by: default avatarHans Verkuil <hansverk@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 21a3f6e5
Loading
Loading
Loading
Loading
+11 −9
Original line number Diff line number Diff line
@@ -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;
@@ -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;
@@ -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;
	}

@@ -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) {
@@ -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;
		}
@@ -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 */
@@ -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);
+2 −1
Original line number Diff line number Diff line
@@ -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];
@@ -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,
+11 −8
Original line number Diff line number Diff line
@@ -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;
@@ -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;
@@ -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;
@@ -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;
	}
@@ -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;

@@ -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);
+3 −1
Original line number Diff line number Diff line
@@ -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];
@@ -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,
+22 −13
Original line number Diff line number Diff line
@@ -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)
@@ -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;

@@ -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;
@@ -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]);
@@ -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;

@@ -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;

@@ -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);
Loading