diff mbox

[v3,0/5] media: ti: cal: Streams support

Message ID 20230302100755.191164-1-tomi.valkeinen@ideasonboard.com (mailing list archive)
State New, archived
Headers show

Commit Message

Tomi Valkeinen March 2, 2023, 10:07 a.m. UTC
Hi,

v2 can be found from:

https://lore.kernel.org/all/20230228171620.330978-1-tomi.valkeinen@ideasonboard.com/

This series is based on Laurent's "media: Zero-initialize structures
passed to subdev pad ops" series and my two patches adding
V4L2_SUBDEV_ROUTING_* flags (v1 of that series).

Only minor changes in v3. Diff to v2 included below.

 Tomi

Tomi Valkeinen (5):
  media: ti: cal: Clean up mbus formats uses
  media: ti: cal: Fix cal_camerarx_create() error handling
  media: ti: cal: Use subdev state
  media: ti: cal: Implement get_frame_desc for camera-rx
  media: ti: cal: Add multiplexed streams support

 drivers/media/platform/ti/cal/cal-camerarx.c | 415 ++++++++++++-------
 drivers/media/platform/ti/cal/cal-video.c    | 142 +++++--
 drivers/media/platform/ti/cal/cal.c          | 109 +++--
 drivers/media/platform/ti/cal/cal.h          |  13 +-
 4 files changed, 416 insertions(+), 263 deletions(-)

Interdiff against v2:

base-commit: 83e0f265aa8d0e37cc8e15d318b64da0ec03ff41
prerequisite-patch-id: e800a6da6afee40be8a946ccf63518f6109749dd
prerequisite-patch-id: eb409cc6ffb895128d98b3fa664dcdcafd5e7dfc
prerequisite-patch-id: dedc1c09e4cff1dc58ce909e469bae30a3778a07
prerequisite-patch-id: 1e85d833252748e723b59f90788019fdeca92884
prerequisite-patch-id: bb4f7477e206ed1936e4632e7baa6514f7d957f4
diff mbox

Patch

diff --git a/drivers/media/platform/ti/cal/cal-camerarx.c b/drivers/media/platform/ti/cal/cal-camerarx.c
index 8e373c817cdf..957aefcacbbc 100644
--- a/drivers/media/platform/ti/cal/cal-camerarx.c
+++ b/drivers/media/platform/ti/cal/cal-camerarx.c
@@ -899,7 +899,7 @@  static int cal_camerarx_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
 		goto out_unlock;
 
 	if (remote_desc.type != V4L2_MBUS_FRAME_DESC_TYPE_CSI2) {
-		dev_err(phy->cal->dev,
+		cal_err(phy->cal,
 			"Frame descriptor does not describe CSI-2 link");
 		ret = -EINVAL;
 		goto out_unlock;
@@ -911,6 +911,8 @@  static int cal_camerarx_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
 	}
 
 	if (i == remote_desc.num_entries) {
+		cal_err(phy->cal, "Stream %u not found in remote frame desc\n",
+			sink_stream);
 		ret = -EINVAL;
 		goto out_unlock;
 	}
@@ -960,7 +962,7 @@  struct cal_camerarx *cal_camerarx_create(struct cal_dev *cal,
 	unsigned int i;
 	int ret;
 
-	phy = kzalloc(sizeof(*phy), GFP_KERNEL);
+	phy = devm_kzalloc(cal->dev, sizeof(*phy), GFP_KERNEL);
 	if (!phy)
 		return ERR_PTR(-ENOMEM);
 
@@ -976,8 +978,7 @@  struct cal_camerarx *cal_camerarx_create(struct cal_dev *cal,
 	phy->base = devm_ioremap_resource(cal->dev, phy->res);
 	if (IS_ERR(phy->base)) {
 		cal_err(cal, "failed to ioremap\n");
-		ret = PTR_ERR(phy->base);
-		goto err_entity_cleanup;
+		return ERR_CAST(phy->base);
 	}
 
 	cal_dbg(1, cal, "ioresource %s at %pa - %pa\n",
@@ -985,11 +986,11 @@  struct cal_camerarx *cal_camerarx_create(struct cal_dev *cal,
 
 	ret = cal_camerarx_regmap_init(cal, phy);
 	if (ret)
-		goto err_entity_cleanup;
+		return ERR_PTR(ret);
 
 	ret = cal_camerarx_parse_dt(phy);
 	if (ret)
-		goto err_entity_cleanup;
+		return ERR_PTR(ret);
 
 	/* Initialize the V4L2 subdev and media entity. */
 	sd = &phy->subdev;
@@ -1006,7 +1007,7 @@  struct cal_camerarx *cal_camerarx_create(struct cal_dev *cal,
 	ret = media_entity_pads_init(&sd->entity, ARRAY_SIZE(phy->pads),
 				     phy->pads);
 	if (ret)
-		goto err_entity_cleanup;
+		goto err_node_put;
 
 	ret = v4l2_subdev_init_finalize(sd);
 	if (ret)
@@ -1022,7 +1023,9 @@  struct cal_camerarx *cal_camerarx_create(struct cal_dev *cal,
 	v4l2_subdev_cleanup(sd);
 err_entity_cleanup:
 	media_entity_cleanup(&phy->subdev.entity);
-	kfree(phy);
+err_node_put:
+	of_node_put(phy->source_ep_node);
+	of_node_put(phy->source_node);
 	return ERR_PTR(ret);
 }
 
@@ -1036,5 +1039,4 @@  void cal_camerarx_destroy(struct cal_camerarx *phy)
 	media_entity_cleanup(&phy->subdev.entity);
 	of_node_put(phy->source_ep_node);
 	of_node_put(phy->source_node);
-	kfree(phy);
 }
diff --git a/drivers/media/platform/ti/cal/cal.c b/drivers/media/platform/ti/cal/cal.c
index 983323a109ac..26ea9134f8ed 100644
--- a/drivers/media/platform/ti/cal/cal.c
+++ b/drivers/media/platform/ti/cal/cal.c
@@ -76,7 +76,7 @@  const struct cal_format_info cal_formats[] = {
 		.code		= MEDIA_BUS_FMT_VYUY8_1X16,
 		.bpp		= 16,
 	}, {
-		.fourcc		= V4L2_PIX_FMT_RGB565, /* gggbbbbb rrrrrggg */
+		.fourcc		= V4L2_PIX_FMT_RGB565,
 		.code		= MEDIA_BUS_FMT_RGB565_1X16,
 		.bpp		= 16,
 	}, {