All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Lechner <david@lechnology.com>
To: "Noralf Trønnes" <noralf@tronnes.org>,
	dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org
Cc: Daniel Vetter <daniel@ffwll.ch>, David Airlie <airlied@linux.ie>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>, Sekhar Nori <nsekhar@ti.com>,
	Kevin Hilman <khilman@kernel.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 4/6] drm/tinydrm: add support for LEGO MINDSTORMS EV3 LCD
Date: Mon, 7 Aug 2017 11:03:36 -0500	[thread overview]
Message-ID: <2abbab73-0314-aaca-29b0-6366452d921b@lechnology.com> (raw)
In-Reply-To: <d814508b-1225-b385-6a90-091487bee2b5@tronnes.org>

On 08/05/2017 01:19 PM, Noralf Trønnes wrote:
> 
> Den 04.08.2017 00.33, skrev David Lechner:
>> +
>> +    buf = kmalloc(len, GFP_KERNEL);
>> +    if (!buf)
>> +        return;
>> +
>> +    tinydrm_xrgb8888_to_gray8(buf, vaddr, fb, clip);
>> +    src = buf;
>> +
>> +    for (y = clip->y1; y < clip->y2; y++) {
>> +        for (x = clip->x1; x < clip->x2; x += 3) {
>> +            val = *src++ & 0xc0;
>> +            if (val & 0xc0)
>> +                val |= 0x20;
>> +            val |= (*src++ & 0xc0) >> 3;
>> +            if (val & 0x18)
>> +                val |= 0x04;
>> +            val |= *src++ >> 6;
>> +            *dst++ = ~val;
> 
> I don't understand how this pixel packing matches the one described in
> the datasheet. Why do you flip the bits at the end?
> 

I a trying to be too clever. :-)

Here is the comment I will add to the next revision:

/*
  * The ST7586 controller has an unusual pixel format where 2bpp 
grayscale is
  * packed 3 pixels per byte with the first two pixels using 3 bits and 
the 3rd
  * pixel using only 2 bits.
  *
  * |  D7  |  D6  |  D5  ||  D1  |  D0  || 2bpp |
  * | (D4) | (D3) | (D2) ||      |      || GRAY |
  * +------+------+------++------+------++------+
  * |  1   |  1   |  1   ||  1   |  1   || 0  0 | black
  * |  1   |  0   |  0   ||  1   |  0   || 0  1 | dark gray
  * |  0   |  1   |  0   ||  0   |  1   || 1  0 | light gray
  * |  0   |  0   |  0   ||  0   |  0   || 1  1 | white
  */


As you can see, in the controller DRAM 1's are black and 0's are white, 
but in the kernel, it is the opposite. Also, if you look at the truth 
table, you can see that the extra 3rd bit has the pattern if D7 == 0 or 
D6 == 0 then D5 is zero.

I suppose it could be better to do this with a lookup table:

static const u8 st7586_lookup[] = { 0x7, 0x4, 0x2, 0x0 };

...

	for (y = clip->y1; y < clip->y2; y++) {
		for (x = clip->x1; x < clip->x2; x += 3) {
			val = st7586_lookup[*src++ >> 6] << 5;
			val |= st7586_lookup[*src++ >> 6] << 2;
			val |= st7586_lookup[*src++ >> 6] >> 1;
			*dst++ = val;
		}
	}

WARNING: multiple messages have this Message-ID (diff)
From: David Lechner <david@lechnology.com>
To: "Noralf Trønnes" <noralf@tronnes.org>,
	dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org
Cc: Mark Rutland <mark.rutland@arm.com>,
	Kevin Hilman <khilman@kernel.org>, Sekhar Nori <nsekhar@ti.com>,
	linux-kernel@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v3 4/6] drm/tinydrm: add support for LEGO MINDSTORMS EV3 LCD
Date: Mon, 7 Aug 2017 11:03:36 -0500	[thread overview]
Message-ID: <2abbab73-0314-aaca-29b0-6366452d921b@lechnology.com> (raw)
In-Reply-To: <d814508b-1225-b385-6a90-091487bee2b5@tronnes.org>

On 08/05/2017 01:19 PM, Noralf Trønnes wrote:
> 
> Den 04.08.2017 00.33, skrev David Lechner:
>> +
>> +    buf = kmalloc(len, GFP_KERNEL);
>> +    if (!buf)
>> +        return;
>> +
>> +    tinydrm_xrgb8888_to_gray8(buf, vaddr, fb, clip);
>> +    src = buf;
>> +
>> +    for (y = clip->y1; y < clip->y2; y++) {
>> +        for (x = clip->x1; x < clip->x2; x += 3) {
>> +            val = *src++ & 0xc0;
>> +            if (val & 0xc0)
>> +                val |= 0x20;
>> +            val |= (*src++ & 0xc0) >> 3;
>> +            if (val & 0x18)
>> +                val |= 0x04;
>> +            val |= *src++ >> 6;
>> +            *dst++ = ~val;
> 
> I don't understand how this pixel packing matches the one described in
> the datasheet. Why do you flip the bits at the end?
> 

I a trying to be too clever. :-)

Here is the comment I will add to the next revision:

/*
  * The ST7586 controller has an unusual pixel format where 2bpp 
grayscale is
  * packed 3 pixels per byte with the first two pixels using 3 bits and 
the 3rd
  * pixel using only 2 bits.
  *
  * |  D7  |  D6  |  D5  ||  D1  |  D0  || 2bpp |
  * | (D4) | (D3) | (D2) ||      |      || GRAY |
  * +------+------+------++------+------++------+
  * |  1   |  1   |  1   ||  1   |  1   || 0  0 | black
  * |  1   |  0   |  0   ||  1   |  0   || 0  1 | dark gray
  * |  0   |  1   |  0   ||  0   |  1   || 1  0 | light gray
  * |  0   |  0   |  0   ||  0   |  0   || 1  1 | white
  */


As you can see, in the controller DRAM 1's are black and 0's are white, 
but in the kernel, it is the opposite. Also, if you look at the truth 
table, you can see that the extra 3rd bit has the pattern if D7 == 0 or 
D6 == 0 then D5 is zero.

I suppose it could be better to do this with a lookup table:

static const u8 st7586_lookup[] = { 0x7, 0x4, 0x2, 0x0 };

...

	for (y = clip->y1; y < clip->y2; y++) {
		for (x = clip->x1; x < clip->x2; x += 3) {
			val = st7586_lookup[*src++ >> 6] << 5;
			val |= st7586_lookup[*src++ >> 6] << 2;
			val |= st7586_lookup[*src++ >> 6] >> 1;
			*dst++ = val;
		}
	}


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

WARNING: multiple messages have this Message-ID (diff)
From: david@lechnology.com (David Lechner)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 4/6] drm/tinydrm: add support for LEGO MINDSTORMS EV3 LCD
Date: Mon, 7 Aug 2017 11:03:36 -0500	[thread overview]
Message-ID: <2abbab73-0314-aaca-29b0-6366452d921b@lechnology.com> (raw)
In-Reply-To: <d814508b-1225-b385-6a90-091487bee2b5@tronnes.org>

On 08/05/2017 01:19 PM, Noralf Tr?nnes wrote:
> 
> Den 04.08.2017 00.33, skrev David Lechner:
>> +
>> +    buf = kmalloc(len, GFP_KERNEL);
>> +    if (!buf)
>> +        return;
>> +
>> +    tinydrm_xrgb8888_to_gray8(buf, vaddr, fb, clip);
>> +    src = buf;
>> +
>> +    for (y = clip->y1; y < clip->y2; y++) {
>> +        for (x = clip->x1; x < clip->x2; x += 3) {
>> +            val = *src++ & 0xc0;
>> +            if (val & 0xc0)
>> +                val |= 0x20;
>> +            val |= (*src++ & 0xc0) >> 3;
>> +            if (val & 0x18)
>> +                val |= 0x04;
>> +            val |= *src++ >> 6;
>> +            *dst++ = ~val;
> 
> I don't understand how this pixel packing matches the one described in
> the datasheet. Why do you flip the bits at the end?
> 

I a trying to be too clever. :-)

Here is the comment I will add to the next revision:

/*
  * The ST7586 controller has an unusual pixel format where 2bpp 
grayscale is
  * packed 3 pixels per byte with the first two pixels using 3 bits and 
the 3rd
  * pixel using only 2 bits.
  *
  * |  D7  |  D6  |  D5  ||  D1  |  D0  || 2bpp |
  * | (D4) | (D3) | (D2) ||      |      || GRAY |
  * +------+------+------++------+------++------+
  * |  1   |  1   |  1   ||  1   |  1   || 0  0 | black
  * |  1   |  0   |  0   ||  1   |  0   || 0  1 | dark gray
  * |  0   |  1   |  0   ||  0   |  1   || 1  0 | light gray
  * |  0   |  0   |  0   ||  0   |  0   || 1  1 | white
  */


As you can see, in the controller DRAM 1's are black and 0's are white, 
but in the kernel, it is the opposite. Also, if you look at the truth 
table, you can see that the extra 3rd bit has the pattern if D7 == 0 or 
D6 == 0 then D5 is zero.

I suppose it could be better to do this with a lookup table:

static const u8 st7586_lookup[] = { 0x7, 0x4, 0x2, 0x0 };

...

	for (y = clip->y1; y < clip->y2; y++) {
		for (x = clip->x1; x < clip->x2; x += 3) {
			val = st7586_lookup[*src++ >> 6] << 5;
			val |= st7586_lookup[*src++ >> 6] << 2;
			val |= st7586_lookup[*src++ >> 6] >> 1;
			*dst++ = val;
		}
	}

  parent reply	other threads:[~2017-08-07 16:03 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-03 22:33 [PATCH v3 0/6] Support for LEGO MINDSTORMS EV3 LCD display David Lechner
2017-08-03 22:33 ` David Lechner
2017-08-03 22:33 ` David Lechner
2017-08-03 22:33 ` [PATCH v3 1/6] drm/tinydrm: remove call to mipi_dbi_init() from mipi_dbi_spi_init() David Lechner
2017-08-03 22:33   ` David Lechner
2017-08-03 22:33   ` David Lechner
2017-08-04 13:16   ` Noralf Trønnes
2017-08-04 13:16     ` Noralf Trønnes
2017-08-04 13:16     ` Noralf Trønnes
2017-08-03 22:33 ` [PATCH v3 2/6] drm/tinydrm: generalize tinydrm_xrgb8888_to_gray8() David Lechner
2017-08-03 22:33   ` David Lechner
2017-08-03 22:33   ` David Lechner
2017-08-04  7:27   ` Noralf Trønnes
2017-08-04  7:27     ` Noralf Trønnes
2017-08-04  7:27     ` Noralf Trønnes
2017-08-04 13:20     ` Noralf Trønnes
2017-08-04 13:20       ` Noralf Trønnes
2017-08-04 13:20       ` Noralf Trønnes
2017-08-03 22:33 ` [PATCH v3 3/6] dt-bindings: add binding for Sitronix ST7586 display panels David Lechner
2017-08-03 22:33   ` David Lechner
2017-08-03 22:33   ` David Lechner
2017-08-04  9:48   ` Noralf Trønnes
2017-08-04  9:48     ` Noralf Trønnes
2017-08-04  9:48     ` Noralf Trønnes
2017-08-04 16:51     ` David Lechner
2017-08-04 16:51       ` David Lechner
2017-08-04 16:51       ` David Lechner
2017-08-04 18:04       ` Noralf Trønnes
2017-08-04 18:04         ` Noralf Trønnes
2017-08-04 18:04         ` Noralf Trønnes
2017-08-04 14:54   ` Laurent Pinchart
2017-08-04 14:54     ` Laurent Pinchart
2017-08-04 14:54     ` Laurent Pinchart
2017-08-04 15:51     ` David Lechner
2017-08-04 15:51       ` David Lechner
2017-08-04 15:51       ` David Lechner
2017-08-04 19:39       ` Laurent Pinchart
2017-08-04 19:39         ` Laurent Pinchart
2017-08-05 16:13         ` David Lechner
2017-08-05 16:13           ` David Lechner
2017-08-05 16:13           ` David Lechner
2017-08-04 17:36     ` Noralf Trønnes
2017-08-04 17:36       ` Noralf Trønnes
2017-08-04 17:36       ` Noralf Trønnes
2017-08-03 22:33 ` [PATCH v3 4/6] drm/tinydrm: add support for LEGO MINDSTORMS EV3 LCD David Lechner
2017-08-03 22:33   ` David Lechner
2017-08-03 22:33   ` David Lechner
2017-08-05 18:19   ` Noralf Trønnes
2017-08-05 18:19     ` Noralf Trønnes
2017-08-05 19:54     ` Noralf Trønnes
2017-08-05 19:54       ` Noralf Trønnes
2017-08-05 19:54       ` Noralf Trønnes
2017-08-07 16:03     ` David Lechner [this message]
2017-08-07 16:03       ` David Lechner
2017-08-07 16:03       ` David Lechner
2017-08-03 22:33 ` [PATCH v3 5/6] ARM: dts: da850-lego-ev3: Add node for LCD display David Lechner
2017-08-03 22:33   ` David Lechner
2017-08-03 22:33 ` [PATCH v3 6/6] ARM: davinci_all_defconfig: enable tinydrm and ST7586 David Lechner
2017-08-03 22:33   ` David Lechner
2017-08-03 22:33   ` David Lechner

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=2abbab73-0314-aaca-29b0-6366452d921b@lechnology.com \
    --to=david@lechnology.com \
    --cc=airlied@linux.ie \
    --cc=daniel@ffwll.ch \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=khilman@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=noralf@tronnes.org \
    --cc=nsekhar@ti.com \
    --cc=robh+dt@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.