drm/ssd130x: Set the page height value in the device info data

The driver only supports OLED controllers that have a page height of 8 but
there are devices that have different page heights. So it is better to not
hardcode this value and instead have it as a per controller data value.
Signed-off-by: default avatarJavier Martinez Canillas <javierm@redhat.com>
Reviewed-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20230609170941.1150941-4-javierm@redhat.com
parent 591825fb
...@@ -102,6 +102,7 @@ const struct ssd130x_deviceinfo ssd130x_variants[] = { ...@@ -102,6 +102,7 @@ const struct ssd130x_deviceinfo ssd130x_variants[] = {
.default_width = 132, .default_width = 132,
.default_height = 64, .default_height = 64,
.page_mode_only = 1, .page_mode_only = 1,
.page_height = 8,
}, },
[SSD1305_ID] = { [SSD1305_ID] = {
.default_vcomh = 0x34, .default_vcomh = 0x34,
...@@ -109,6 +110,7 @@ const struct ssd130x_deviceinfo ssd130x_variants[] = { ...@@ -109,6 +110,7 @@ const struct ssd130x_deviceinfo ssd130x_variants[] = {
.default_dclk_frq = 7, .default_dclk_frq = 7,
.default_width = 132, .default_width = 132,
.default_height = 64, .default_height = 64,
.page_height = 8,
}, },
[SSD1306_ID] = { [SSD1306_ID] = {
.default_vcomh = 0x20, .default_vcomh = 0x20,
...@@ -117,6 +119,7 @@ const struct ssd130x_deviceinfo ssd130x_variants[] = { ...@@ -117,6 +119,7 @@ const struct ssd130x_deviceinfo ssd130x_variants[] = {
.need_chargepump = 1, .need_chargepump = 1,
.default_width = 128, .default_width = 128,
.default_height = 64, .default_height = 64,
.page_height = 8,
}, },
[SSD1307_ID] = { [SSD1307_ID] = {
.default_vcomh = 0x20, .default_vcomh = 0x20,
...@@ -125,6 +128,7 @@ const struct ssd130x_deviceinfo ssd130x_variants[] = { ...@@ -125,6 +128,7 @@ const struct ssd130x_deviceinfo ssd130x_variants[] = {
.need_pwm = 1, .need_pwm = 1,
.default_width = 128, .default_width = 128,
.default_height = 39, .default_height = 39,
.page_height = 8,
}, },
[SSD1309_ID] = { [SSD1309_ID] = {
.default_vcomh = 0x34, .default_vcomh = 0x34,
...@@ -132,6 +136,7 @@ const struct ssd130x_deviceinfo ssd130x_variants[] = { ...@@ -132,6 +136,7 @@ const struct ssd130x_deviceinfo ssd130x_variants[] = {
.default_dclk_frq = 10, .default_dclk_frq = 10,
.default_width = 128, .default_width = 128,
.default_height = 64, .default_height = 64,
.page_height = 8,
} }
}; };
EXPORT_SYMBOL_NS_GPL(ssd130x_variants, DRM_SSD130X); EXPORT_SYMBOL_NS_GPL(ssd130x_variants, DRM_SSD130X);
...@@ -437,7 +442,8 @@ static int ssd130x_update_rect(struct ssd130x_device *ssd130x, u8 *buf, ...@@ -437,7 +442,8 @@ static int ssd130x_update_rect(struct ssd130x_device *ssd130x, u8 *buf,
unsigned int width = drm_rect_width(rect); unsigned int width = drm_rect_width(rect);
unsigned int height = drm_rect_height(rect); unsigned int height = drm_rect_height(rect);
unsigned int line_length = DIV_ROUND_UP(width, 8); unsigned int line_length = DIV_ROUND_UP(width, 8);
unsigned int pages = DIV_ROUND_UP(height, 8); unsigned int page_height = ssd130x->device_info->page_height;
unsigned int pages = DIV_ROUND_UP(height, page_height);
struct drm_device *drm = &ssd130x->drm; struct drm_device *drm = &ssd130x->drm;
u32 array_idx = 0; u32 array_idx = 0;
int ret, i, j, k; int ret, i, j, k;
...@@ -559,16 +565,17 @@ static int ssd130x_fb_blit_rect(struct drm_framebuffer *fb, const struct iosys_m ...@@ -559,16 +565,17 @@ static int ssd130x_fb_blit_rect(struct drm_framebuffer *fb, const struct iosys_m
struct drm_rect *rect) struct drm_rect *rect)
{ {
struct ssd130x_device *ssd130x = drm_to_ssd130x(fb->dev); struct ssd130x_device *ssd130x = drm_to_ssd130x(fb->dev);
unsigned int page_height = ssd130x->device_info->page_height;
struct iosys_map dst; struct iosys_map dst;
unsigned int dst_pitch; unsigned int dst_pitch;
int ret = 0; int ret = 0;
u8 *buf = NULL; u8 *buf = NULL;
/* Align y to display page boundaries */ /* Align y to display page boundaries */
rect->y1 = round_down(rect->y1, 8); rect->y1 = round_down(rect->y1, page_height);
rect->y2 = min_t(unsigned int, round_up(rect->y2, 8), ssd130x->height); rect->y2 = min_t(unsigned int, round_up(rect->y2, page_height), ssd130x->height);
dst_pitch = DIV_ROUND_UP(drm_rect_width(rect), 8); dst_pitch = DIV_ROUND_UP(drm_rect_width(rect), page_height);
buf = kcalloc(dst_pitch, drm_rect_height(rect), GFP_KERNEL); buf = kcalloc(dst_pitch, drm_rect_height(rect), GFP_KERNEL);
if (!buf) if (!buf)
return -ENOMEM; return -ENOMEM;
......
...@@ -39,6 +39,7 @@ struct ssd130x_deviceinfo { ...@@ -39,6 +39,7 @@ struct ssd130x_deviceinfo {
u32 default_dclk_frq; u32 default_dclk_frq;
u32 default_width; u32 default_width;
u32 default_height; u32 default_height;
u32 page_height;
int need_pwm; int need_pwm;
int need_chargepump; int need_chargepump;
bool page_mode_only; bool page_mode_only;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment