The definition is used to publish hardware constraints and can be used
to implement in-demand device configuration.

Signed-off-by: Alexander Riesen <alexander.rie...@cetitec.com>
---
 drivers/media/i2c/adv748x/adv748x-core.c | 33 ++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/drivers/media/i2c/adv748x/adv748x-core.c 
b/drivers/media/i2c/adv748x/adv748x-core.c
index b6067ffb1e0d..75e4bf144ad7 100644
--- a/drivers/media/i2c/adv748x/adv748x-core.c
+++ b/drivers/media/i2c/adv748x/adv748x-core.c
@@ -25,6 +25,7 @@
 #include <media/v4l2-dv-timings.h>
 #include <media/v4l2-fwnode.h>
 #include <media/v4l2-ioctl.h>
+#include <sound/soc.h>
 
 #include "adv748x.h"
 
@@ -689,6 +690,30 @@ static void adv748x_dt_cleanup(struct adv748x_state *state)
                of_node_put(state->endpoints[i]);
 }
 
+static struct snd_soc_dai_driver adv748x_dai = {
+       .name = "adv748x-i2s",
+       .capture = {
+               .stream_name    = "Capture",
+               .channels_min   = 8,
+               .channels_max   = 8,
+               .rates = SNDRV_PCM_RATE_48000,
+               .formats = SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_U24_LE,
+        },
+};
+
+static int adv748x_of_xlate_dai_name(struct snd_soc_component *component,
+                                     struct of_phandle_args *args,
+                                     const char **dai_name)
+{
+       if (dai_name)
+               *dai_name = adv748x_dai.name;
+       return 0;
+}
+
+static const struct snd_soc_component_driver adv748x_codec = {
+       .of_xlate_dai_name = adv748x_of_xlate_dai_name,
+};
+
 static int adv748x_probe(struct i2c_client *client)
 {
        struct adv748x_state *state;
@@ -782,8 +807,16 @@ static int adv748x_probe(struct i2c_client *client)
                goto err_cleanup_txa;
        }
 
+       ret = devm_snd_soc_register_component(state->dev, &adv748x_codec,
+                                             &adv748x_dai, 1);
+       if (ret < 0) {
+               adv_err(state, "Failed to register the codec");
+               goto err_cleanup_txb;
+       }
        return 0;
 
+err_cleanup_txb:
+       adv748x_csi2_cleanup(&state->txb);
 err_cleanup_txa:
        adv748x_csi2_cleanup(&state->txa);
 err_cleanup_afe:
-- 
2.24.1.508.g91d2dafee0

_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to