From: Amit Barzilai <amit.barzilai22@gmail.com>
To: Javier Martinez Canillas <javierm@redhat.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>
Cc: Jocelyn Falempe <jfalempe@redhat.com>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
Amit Barzilai <amit.barzilai22@gmail.com>
Subject: [PATCH 2/3] drm/ssd130x: hoist column and row addresses out of repeated division
Date: Mon, 22 Jun 2026 15:26:03 +0300 [thread overview]
Message-ID: <20260622122604.32500-3-amit.barzilai22@gmail.com> (raw)
In-Reply-To: <20260622122604.32500-1-amit.barzilai22@gmail.com>
The ssd132x_update_rect had to calculate the column address twice in
the same function by dividing the byte address and the segment_width.
Optimize this by hoisting the result into a col variable.
Renamed the "y" variable to "row" to match the change made in the x
axis.
Signed-off-by: Amit Barzilai <amit.barzilai22@gmail.com>
---
drivers/gpu/drm/solomon/ssd130x.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/solomon/ssd130x.c b/drivers/gpu/drm/solomon/ssd130x.c
index 77aa5585a46c..fee35496a324 100644
--- a/drivers/gpu/drm/solomon/ssd130x.c
+++ b/drivers/gpu/drm/solomon/ssd130x.c
@@ -835,9 +835,9 @@ static int ssd132x_update_rect(struct ssd130x_device *ssd130x,
struct drm_rect *rect, u8 *buf,
u8 *data_array)
{
- unsigned int x = rect->x1;
- unsigned int y = rect->y1;
unsigned int segment_width = SSD132X_SEGMENT_WIDTH;
+ unsigned int col = rect->x1 / segment_width;
+ unsigned int row = rect->y1;
unsigned int width = drm_rect_width(rect);
unsigned int height = drm_rect_height(rect);
unsigned int columns = DIV_ROUND_UP(width, segment_width);
@@ -847,7 +847,7 @@ static int ssd132x_update_rect(struct ssd130x_device *ssd130x,
unsigned int i, j;
int ret;
- drm_WARN_ONCE(drm, x % segment_width != 0, "x must be aligned to screen segment\n");
+ drm_WARN_ONCE(drm, rect->x1 % segment_width != 0, "x must be aligned to screen segment\n");
/*
* The screen is divided in Segment and Common outputs, where
@@ -864,13 +864,12 @@ static int ssd132x_update_rect(struct ssd130x_device *ssd130x,
*/
/* Set column start and end */
- ret = ssd130x_write_cmd(ssd130x, 3, SSD132X_SET_COL_RANGE, x / segment_width,
- x / segment_width + columns - 1);
+ ret = ssd130x_write_cmd(ssd130x, 3, SSD132X_SET_COL_RANGE, col, col + columns - 1);
if (ret < 0)
return ret;
/* Set row start and end */
- ret = ssd130x_write_cmd(ssd130x, 3, SSD132X_SET_ROW_RANGE, y, y + rows - 1);
+ ret = ssd130x_write_cmd(ssd130x, 3, SSD132X_SET_ROW_RANGE, row, row + rows - 1);
if (ret < 0)
return ret;
--
2.54.0
next prev parent reply other threads:[~2026-06-22 12:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-22 12:26 [PATCH 0/3] drm/ssd130x: fix column and row end address in partial updates of ssd132x and ssd133x devices Amit Barzilai
2026-06-22 12:26 ` [PATCH 1/3] drm/ssd130x: fix column and row end address in partial updates for ssd132x Amit Barzilai
2026-06-22 12:26 ` Amit Barzilai [this message]
2026-06-22 12:26 ` [PATCH 3/3] drm/ssd130x: fix column and row end address in partial updates in ssd133x Amit Barzilai
2026-07-01 13:23 ` [PATCH 0/3] drm/ssd130x: fix column and row end address in partial updates of ssd132x and ssd133x devices Javier Martinez Canillas
2026-07-06 10:41 ` Javier Martinez Canillas
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=20260622122604.32500-3-amit.barzilai22@gmail.com \
--to=amit.barzilai22@gmail.com \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=javierm@redhat.com \
--cc=jfalempe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/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
all inboxes | Powered by JetHome®