Re: [PATCH v4 4/6] media: qcom: camss: Add sc8280xp resource details

From: Bryan O'Donoghue
Date: Thu Nov 09 2023 - 10:14:12 EST


On 09/11/2023 13:44, Konrad Dybcio wrote:
+        .clock_rate = { { 0 },
+                { 0 },
+                { 19200000, 80000000, 80000000, 80000000, 80000000},
+                { 19200000, 150000000, 266666667, 320000000, 400000000, 480000000 },
+                { 400000000, 558000000, 637000000, 760000000 },
+                { 0 }, },
Not the case here!

I agree with you in principle, the checking for the frequency shouldn't rely on if (freq[x]) however in this case - we are doing aggregate initialisation of a fixed size array and the compiler should save us from ourselves.

./test
index 19200000 = 0
index 80000000 = 4
index 80000000 = 8
index 80000000 = 12
index 80000000 = 16
index 0 = 20
index 0 = 24
index 0 = 28
index 0 = 32
index 0 = 36
index 0 = 40
index 0 = 44
index 0 = 48
index 0 = 52
index 0 = 56
index 0 = 60
index 0 = 64

deckard@sagittarius-a:~/Development/qualcomm/qlt-kernel$ cat test.c
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define CAMSS_RES_MAX 17

unsigned int clock_rate[CAMSS_RES_MAX][CAMSS_RES_MAX] = {
{ 19200000, 80000000, 80000000, 80000000, 80000000},
};

int main (int argc, char *argv[])
{
int i;

for (i = 0; i < CAMSS_RES_MAX; i++) {
printf("index %d = %d\n", clock_rate[0][i]);
}

return 0;
}

However this code only works at the moment by happenstance not by design so, I will drop something separate to this series to remediate.

---
bod