From fa6164a3a498c1e2a237d61e784d5104b4ef54e4 Mon Sep 17 00:00:00 2001
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
Date: Tue, 23 Jul 2024 11:27:16 +0100
Subject: [PATCH] media: platform: Move bcm2835-unicam compatible to downstream
 driver

The upstream Unicam driver needs a set of userland changes to get
libcamera to run, and those aren't written or merged yet.

Move the "brcm,bcm2835-unicam" compatible from the upstream driver
to the old downstream version so that users can run libcamera
against 6.10.
Once the libcamera changes have been merged this can be reverted
to use the upstream driver.

If using the non-legacy compatible then assume we want to use
media-controller API for configuration.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
---
 drivers/media/platform/bcm2835/bcm2835-unicam.c  | 8 +++++++-
 drivers/media/platform/broadcom/bcm2835-unicam.c | 2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)

--- a/drivers/media/platform/bcm2835/bcm2835-unicam.c
+++ b/drivers/media/platform/bcm2835/bcm2835-unicam.c
@@ -3381,6 +3381,11 @@ static int unicam_probe(struct platform_
 	 * device tree requests it.
 	 */
 	unicam->mc_api = media_controller;
+
+	/* Compatible is for the non-legacy version of the driver - use compatible */
+	if (of_device_get_match_data(&unicam->pdev->dev))
+		unicam->mc_api = true;
+
 	if (of_property_read_bool(pdev->dev.of_node, "brcm,media-controller"))
 		unicam->mc_api = true;
 
@@ -3500,7 +3505,8 @@ static void unicam_remove(struct platfor
 }
 
 static const struct of_device_id unicam_of_match[] = {
-	{ .compatible = "brcm,bcm2835-unicam-legacy", },
+	{ .compatible = "brcm,bcm2835-unicam", .data = (void *)1 },
+	{ .compatible = "brcm,bcm2835-unicam-legacy", .data = 0 },
 	{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, unicam_of_match);
--- a/drivers/media/platform/broadcom/bcm2835-unicam.c
+++ b/drivers/media/platform/broadcom/bcm2835-unicam.c
@@ -2735,7 +2735,7 @@ static void unicam_remove(struct platfor
 }
 
 static const struct of_device_id unicam_of_match[] = {
-	{ .compatible = "brcm,bcm2835-unicam", },
+	{ .compatible = "brcm,bcm2835-unicam-upstream", },
 	{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, unicam_of_match);
