Skip to content

Commit 66c0930

Browse files
Martijn VersteeghMartijn Versteegh
authored andcommitted
fbtft: Add a sysfs parameter to set the vertical scrolling position on a window.
Add a sysfs param scroll_pos which sets the scanline where the display starts for 'rolling scrolling'. This needs support from the specific display driver as well. When supported it can be used to implement smooth vertical (when the display is in portrait mode) hor horizontal (when the display is used in landscape mode) scrolling by strategically changing the start scanline of the display and erasing/redrawing only the wrapping part. This way you never need to redraw what's already there, preventing slow full screen redraws over spi.
1 parent 1418a05 commit 66c0930

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

drivers/staging/fbtft/fbtft-core.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,9 @@ static void fbtft_merge_fbtftops(struct fbtft_ops *dst, struct fbtft_ops *src)
623623
dst->set_var = src->set_var;
624624
if (src->set_gamma)
625625
dst->set_gamma = src->set_gamma;
626+
if (src->set_scroll)
627+
dst->set_scroll = src->set_scroll;
628+
626629
}
627630

628631
/**

drivers/staging/fbtft/fbtft-sysfs.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,16 +204,55 @@ static ssize_t show_debug(struct device *device,
204204
static struct device_attribute debug_device_attr = \
205205
__ATTR(debug, 0660, show_debug, store_debug);
206206

207+
208+
209+
static ssize_t store_scroll(struct device *device,
210+
struct device_attribute *attr,
211+
const char *buf, size_t count)
212+
{
213+
struct fb_info *fb_info = dev_get_drvdata(device);
214+
struct fbtft_par *par = fb_info->par;
215+
int ret;
216+
217+
ret = kstrtoul(buf, 10, &par->scroll_pos);
218+
219+
if (ret)
220+
return ret;
221+
222+
if (par->fbtftops.set_scroll)
223+
par->fbtftops.set_scroll(par);
224+
225+
226+
return count;
227+
}
228+
229+
static ssize_t show_scroll(struct device *device,
230+
struct device_attribute *attr, char *buf)
231+
{
232+
struct fb_info *fb_info = dev_get_drvdata(device);
233+
struct fbtft_par *par = fb_info->par;
234+
235+
return snprintf(buf, PAGE_SIZE, "%lu\n", par->scroll_pos);
236+
}
237+
238+
static struct device_attribute scroll_pos_device_attr = \
239+
__ATTR(scroll_pos, 0660, show_scroll, store_scroll);
240+
241+
207242
void fbtft_sysfs_init(struct fbtft_par *par)
208243
{
209244
device_create_file(par->info->dev, &debug_device_attr);
245+
if (par->fbtftops.set_scroll)
246+
device_create_file(par->info->dev, &scroll_pos_device_attr);
210247
if (par->gamma.curves && par->fbtftops.set_gamma)
211248
device_create_file(par->info->dev, &gamma_device_attrs[0]);
212249
}
213250

214251
void fbtft_sysfs_exit(struct fbtft_par *par)
215252
{
216253
device_remove_file(par->info->dev, &debug_device_attr);
254+
if (par->fbtftops.set_scroll)
255+
device_remove_file(par->info->dev, &scroll_pos_device_attr);
217256
if (par->gamma.curves && par->fbtftops.set_gamma)
218257
device_remove_file(par->info->dev, &gamma_device_attrs[0]);
219258
}

drivers/staging/fbtft/fbtft.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ struct fbtft_ops {
9393

9494
int (*set_var)(struct fbtft_par *par);
9595
int (*set_gamma)(struct fbtft_par *par, unsigned long *curves);
96+
void (*set_scroll)(struct fbtft_par *par);
9697
};
9798

9899
/**
@@ -240,6 +241,7 @@ struct fbtft_par {
240241
bool first_update_done;
241242
ktime_t update_time;
242243
bool bgr;
244+
unsigned long scroll_pos;
243245
void *extra;
244246
};
245247

0 commit comments

Comments
 (0)