diff mbox series

media: venus: pm_helpers: Unify v3 and v4 venc/vdec_get

Message ID 20230811-topic-venus_dedup-v1-1-c4b4af499ef2@linaro.org
State New
Headers show
Series media: venus: pm_helpers: Unify v3 and v4 venc/vdec_get | expand

Commit Message

Konrad Dybcio Aug. 11, 2023, 11:12 a.m. UTC
They do the same thing, except v3 and earlier are expected to have the
old style of bindings (i.e. core clock per core under video-enc/decoder
subnode).

Unify them to stop duplicating needlessly.

Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
 drivers/media/platform/qcom/venus/pm_helpers.c | 34 ++++++++------------------
 1 file changed, 10 insertions(+), 24 deletions(-)


---
base-commit: 21ef7b1e17d039053edaeaf41142423810572741
change-id: 20230811-topic-venus_dedup-08f183d3a611

Best regards,

Comments

Konrad Dybcio Aug. 11, 2023, 11:56 a.m. UTC | #1
On 11.08.2023 13:52, Bryan O'Donoghue wrote:
> On 11/08/2023 12:12, Konrad Dybcio wrote:
>> They do the same thing, except v3 and earlier are expected to have the
>> old style of bindings (i.e. core clock per core under video-enc/decoder
>> subnode).
>>
>> Unify them to stop duplicating needlessly.
>>
>> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
>> ---
>>   drivers/media/platform/qcom/venus/pm_helpers.c | 34 ++++++++------------------
>>   1 file changed, 10 insertions(+), 24 deletions(-)
>>
>> diff --git a/drivers/media/platform/qcom/venus/pm_helpers.c b/drivers/media/platform/qcom/venus/pm_helpers.c
>> index 48c9084bb4db..83d1e68bb9ca 100644
>> --- a/drivers/media/platform/qcom/venus/pm_helpers.c
>> +++ b/drivers/media/platform/qcom/venus/pm_helpers.c
>> @@ -295,6 +295,8 @@ static int core_get_v1(struct venus_core *core)
>>   {
>>       int ret;
>>   +    legacy_binding = true;
>> +
>>       ret = core_clks_get(core);
>>       if (ret)
>>           return ret;
>> @@ -349,6 +351,9 @@ static int vdec_get_v3(struct device *dev)
>>   {
>>       struct venus_core *core = dev_get_drvdata(dev);
>>   +    if (!legacy_binding)
>> +        return 0;
>> +
>>       return vcodec_clks_get(core, dev, core->vcodec0_clks,
>>                      core->res->vcodec0_clks);
>>   }
>> @@ -374,6 +379,9 @@ static int venc_get_v3(struct device *dev)
>>   {
>>       struct venus_core *core = dev_get_drvdata(dev);
>>   +    if (!legacy_binding)
>> +        return 0;
>> +
>>       return vcodec_clks_get(core, dev, core->vcodec1_clks,
>>                      core->res->vcodec1_clks);
>>   }
>> @@ -764,17 +772,6 @@ static int coreid_power_v4(struct venus_inst *inst, int on)
>>       return ret;
>>   }
>>   -static int vdec_get_v4(struct device *dev)
>> -{
>> -    struct venus_core *core = dev_get_drvdata(dev);
>> -
>> -    if (!legacy_binding)
>> -        return 0;
>> -
>> -    return vcodec_clks_get(core, dev, core->vcodec0_clks,
>> -                   core->res->vcodec0_clks);
>> -}
>> -
>>   static void vdec_put_v4(struct device *dev)
>>   {
>>       struct venus_core *core = dev_get_drvdata(dev);
>> @@ -809,17 +806,6 @@ static int vdec_power_v4(struct device *dev, int on)
>>       return ret;
>>   }
>>   -static int venc_get_v4(struct device *dev)
>> -{
>> -    struct venus_core *core = dev_get_drvdata(dev);
>> -
>> -    if (!legacy_binding)
>> -        return 0;
>> -
>> -    return vcodec_clks_get(core, dev, core->vcodec1_clks,
>> -                   core->res->vcodec1_clks);
>> -}
>> -
>>   static void venc_put_v4(struct device *dev)
>>   {
>>       struct venus_core *core = dev_get_drvdata(dev);
>> @@ -1180,10 +1166,10 @@ static const struct venus_pm_ops pm_ops_v4 = {
>>       .core_get = core_get_v4,
>>       .core_put = core_put_v4,
>>       .core_power = core_power_v4,
>> -    .vdec_get = vdec_get_v4,
>> +    .vdec_get = vdec_get_v3,
>>       .vdec_put = vdec_put_v4,
>>       .vdec_power = vdec_power_v4,
>> -    .venc_get = venc_get_v4,
>> +    .venc_get = venc_get_v3,
>>       .venc_put = venc_put_v4,
>>       .venc_power = venc_power_v4,
>>       .coreid_power = coreid_power_v4,
>>
>> ---
>> base-commit: 21ef7b1e17d039053edaeaf41142423810572741
>> change-id: 20230811-topic-venus_dedup-08f183d3a611
>>
>> Best regards,
> 
> This makes sense.
> 
> It'd be nice to get rid of the top-level static bool and bury it in the core venus structure but, that's not a problem with your patch.
That's the plan, just that untangling this mess will take some time

Konrad
diff mbox series

Patch

diff --git a/drivers/media/platform/qcom/venus/pm_helpers.c b/drivers/media/platform/qcom/venus/pm_helpers.c
index 48c9084bb4db..83d1e68bb9ca 100644
--- a/drivers/media/platform/qcom/venus/pm_helpers.c
+++ b/drivers/media/platform/qcom/venus/pm_helpers.c
@@ -295,6 +295,8 @@  static int core_get_v1(struct venus_core *core)
 {
 	int ret;
 
+	legacy_binding = true;
+
 	ret = core_clks_get(core);
 	if (ret)
 		return ret;
@@ -349,6 +351,9 @@  static int vdec_get_v3(struct device *dev)
 {
 	struct venus_core *core = dev_get_drvdata(dev);
 
+	if (!legacy_binding)
+		return 0;
+
 	return vcodec_clks_get(core, dev, core->vcodec0_clks,
 			       core->res->vcodec0_clks);
 }
@@ -374,6 +379,9 @@  static int venc_get_v3(struct device *dev)
 {
 	struct venus_core *core = dev_get_drvdata(dev);
 
+	if (!legacy_binding)
+		return 0;
+
 	return vcodec_clks_get(core, dev, core->vcodec1_clks,
 			       core->res->vcodec1_clks);
 }
@@ -764,17 +772,6 @@  static int coreid_power_v4(struct venus_inst *inst, int on)
 	return ret;
 }
 
-static int vdec_get_v4(struct device *dev)
-{
-	struct venus_core *core = dev_get_drvdata(dev);
-
-	if (!legacy_binding)
-		return 0;
-
-	return vcodec_clks_get(core, dev, core->vcodec0_clks,
-			       core->res->vcodec0_clks);
-}
-
 static void vdec_put_v4(struct device *dev)
 {
 	struct venus_core *core = dev_get_drvdata(dev);
@@ -809,17 +806,6 @@  static int vdec_power_v4(struct device *dev, int on)
 	return ret;
 }
 
-static int venc_get_v4(struct device *dev)
-{
-	struct venus_core *core = dev_get_drvdata(dev);
-
-	if (!legacy_binding)
-		return 0;
-
-	return vcodec_clks_get(core, dev, core->vcodec1_clks,
-			       core->res->vcodec1_clks);
-}
-
 static void venc_put_v4(struct device *dev)
 {
 	struct venus_core *core = dev_get_drvdata(dev);
@@ -1180,10 +1166,10 @@  static const struct venus_pm_ops pm_ops_v4 = {
 	.core_get = core_get_v4,
 	.core_put = core_put_v4,
 	.core_power = core_power_v4,
-	.vdec_get = vdec_get_v4,
+	.vdec_get = vdec_get_v3,
 	.vdec_put = vdec_put_v4,
 	.vdec_power = vdec_power_v4,
-	.venc_get = venc_get_v4,
+	.venc_get = venc_get_v3,
 	.venc_put = venc_put_v4,
 	.venc_power = venc_power_v4,
 	.coreid_power = coreid_power_v4,