public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 2/6] tools/intel_scaler_coef: Add support for chv plane scaler coefficients
Date: Tue, 10 Mar 2020 16:18:26 +0200	[thread overview]
Message-ID: <20200310141830.8040-2-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20200310141830.8040-1-ville.syrjala@linux.intel.com>

From: Ville Syrjälä <ville.syrjala@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@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

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  reply	other threads:[~2020-03-10 14:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-10 14:18 [igt-dev] [PATCH i-g-t 1/6] tools/intel_scaler_coef: Add a tool for calculating scaler coefficients Ville Syrjala
2020-03-10 14:18 ` Ville Syrjala [this message]
2020-03-10 14:18 ` [igt-dev] [PATCH i-g-t 3/6] HACK: tools/intel_scaler_coef: Test ilk/snb/ivb panel fitter programmable coefficients Ville Syrjala
2020-03-10 14:18 ` [igt-dev] [PATCH i-g-t 4/6] HACK: tools/intel_scaler_coef: Test cnl+ pipe scaler " Ville Syrjala
2020-03-10 14:18 ` [igt-dev] [PATCH i-g-t 5/6] HACK: tools/intel_scaler_coef: Test chv plane " Ville Syrjala
2020-03-10 14:18 ` [igt-dev] [PATCH i-g-t 6/6] HACK: lib/igt_fb: Paint diagonals Ville Syrjala
2020-03-10 15:21 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/6] tools/intel_scaler_coef: Add a tool for calculating scaler coefficients Patchwork
2020-03-10 19:26 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200310141830.8040-2-ville.syrjala@linux.intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox