[igt-dev] [PATCH i-g-t 2/6] tools/intel_scaler_coef: Add support for chv plane scaler coefficients
Ville Syrjala
ville.syrjala at linux.intel.com
Tue Mar 10 14:18:26 UTC 2020
From: Ville Syrjälä <ville.syrjala at linux.intel.com>
CHV pipe B primary plane has a scaler. It's totally alien hardware
and thus requires its own style of scaler coefficients.
Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
tools/intel_scaler_coef.c | 92 +++++++++++++++++++++++++++++++++++++++
1 file changed, 92 insertions(+)
diff --git a/tools/intel_scaler_coef.c b/tools/intel_scaler_coef.c
index 19e247ab266a..a85af924fb6b 100644
--- a/tools/intel_scaler_coef.c
+++ b/tools/intel_scaler_coef.c
@@ -61,6 +61,8 @@ enum coef_format {
FORMAT_ILK_PF_VERT_5TAP,
FORMAT_ILK_PF_VERT_3TAP,
FORMAT_CNL_PS,
+ FORMAT_CHV_HORZ,
+ FORMAT_CHV_VERT,
FORMAT_INVALID,
};
@@ -73,6 +75,8 @@ static const char * const coef_formats[] = {
[FORMAT_ILK_PF_VERT_5TAP] = "ilk_pf_vert_5tap",
[FORMAT_ILK_PF_VERT_3TAP] = "ilk_pf_vert_3tap",
[FORMAT_CNL_PS] = "cnl_ps",
+ [FORMAT_CHV_HORZ] = "chv_horz",
+ [FORMAT_CHV_VERT] = "chv_vert",
};
enum filter_mode {
@@ -441,6 +445,9 @@ static int tap_to_hwtap(const struct filter *f, int t)
static const int ilk_pf_vert_3tap_hwtaps[] = { 0, 2, 4 };
static const int cnl_ps_hwtaps[] = { 6, 5, 4, 3, 2, 1, 0 };
+static const int chv_horz_hwtaps[] = { 8, 7, 6, 5, 4, 3, 2, 1, 0 };
+static const int chv_vert_hwtaps[] = { 4, 3, 2, 1, 0 };
+
static const struct filter_config configs[] = {
[FORMAT_OVL_Y_HORZ] = {
.ntaps = 5, .nphases = 32,
@@ -495,6 +502,16 @@ static const struct filter_config configs[] = {
.format = FORMAT_CNL_PS,
.hwtaps = cnl_ps_hwtaps, .nhwtaps = 7,
},
+ [FORMAT_CHV_HORZ] = {
+ .ntaps = 9, .nphases = 32,
+ .format = FORMAT_CHV_HORZ,
+ .hwtaps = chv_horz_hwtaps, .nhwtaps = 9,
+ },
+ [FORMAT_CHV_VERT] = {
+ .ntaps = 5, .nphases = 32,
+ .format = FORMAT_CHV_VERT,
+ .hwtaps = chv_vert_hwtaps, .nhwtaps = 5,
+ },
};
/*
@@ -620,9 +637,64 @@ static void gen2_update_tap(struct filter *f, int p, int t)
coefs[t] = gen2_reg_to_coef(f, t, &r);
}
+/*
+ * chv plane scaler filter coefficient hardware register layout
+ */
+union chv_coef_reg
+{
+ uint16_t reg; /* s2.10 */
+};
+
+static int sign_extend(int reg, int bits)
+{
+ bits = 32 - bits;
+
+ return (reg << bits) >> bits;
+}
+
+static double chv_reg_to_coef(const union chv_coef_reg *r)
+{
+ double c = sign_extend(r->reg, 12);
+
+ return c / (1 << 10);
+}
+
+static void chv_coef_to_reg(const struct filter *f,
+ double coef,
+ union chv_coef_reg *r)
+{
+ int max = 2 << 10;
+ int c = coef * (1 << 10);
+
+ if (!f->strict)
+ c = clamp(c, -max, max-1);
+
+ if (c >= -max && c < max) {
+ r->reg = c & 0xfff;
+ return;
+ }
+
+ fprintf(stderr, "Unable to represent %f in hardware format\n", coef);
+ assert(0);
+}
+
+static void chv_update_tap(struct filter *f, int p, int t)
+{
+ double *coefs = f->phases[p].coefs;
+ union chv_coef_reg r;
+
+ chv_coef_to_reg(f, coefs[t], &r);
+
+ coefs[t] = chv_reg_to_coef(&r);
+}
+
static void update_tap(struct filter *f, int p, int t)
{
switch (f->config.format) {
+ case FORMAT_CHV_HORZ:
+ case FORMAT_CHV_VERT:
+ chv_update_tap(f, p, t);
+ break;
default:
gen2_update_tap(f, p, t);
break;
@@ -767,6 +839,17 @@ static void hw_print_filter(const struct filter *f)
/* sum in .16 binary fixed point */
sum += sign_to_int(r.sign) * r.mantissa << (5 - exp);
+ printf(" %04x", r.reg);
+ }
+ break;
+ case FORMAT_CHV_HORZ:
+ case FORMAT_CHV_VERT: {
+ union chv_coef_reg r;
+
+ chv_coef_to_reg(f, coefs[t], &r);
+
+ sum += sign_extend(r.reg, 12);
+
printf(" %04x", r.reg);
}
break;
@@ -804,6 +887,15 @@ static void print_c_filter(const struct filter *f)
gen2_coef_to_reg(f, t, coef, &r);
+ printf(" 0x%04x,", r.reg);
+ }
+ break;
+ case FORMAT_CHV_HORZ:
+ case FORMAT_CHV_VERT: {
+ union chv_coef_reg r;
+
+ chv_coef_to_reg(f, coefs[t], &r);
+
printf(" 0x%04x,", r.reg);
}
break;
--
2.24.1
More information about the igt-dev
mailing list