mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 04:34:03 +02:00
drm/ssd130x: hoist column and row addresses out of repeated division
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> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://patch.msgid.link/20260622122604.32500-3-amit.barzilai22@gmail.com Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
This commit is contained in:
parent
99e9c09358
commit
2f1ac69c06
|
|
@ -725,9 +725,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);
|
||||
|
|
@ -737,7 +737,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
|
||||
|
|
@ -754,13 +754,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;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user