Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions drivers/staging/fbtft/fb_hx8357d.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ static int init_display(struct fbtft_par *par)
/* tear line */
write_reg(par, MIPI_DCS_SET_TEAR_SCANLINE, 0x00, 0x02);

/* set scrolling are to whole screen*/
write_reg(par, HX8357D_VSCRDEF, 0x00, 0x00, 0x1, 0xE0, 0x00, 0x00);

/* Exit Sleep */
write_reg(par, MIPI_DCS_EXIT_SLEEP_MODE);
msleep(150);
Expand Down Expand Up @@ -182,9 +185,16 @@ static int set_var(struct fbtft_par *par)
/* Memory Access Control */
write_reg(par, MIPI_DCS_SET_ADDRESS_MODE, val);

write_reg(par, HX8357D_VSCRADD, ((par->scroll_pos) >> 8) & 0xFF, (par->scroll_pos) & 0xFF);

return 0;
}

static void set_scroll(struct fbtft_par *par)
{
write_reg(par, HX8357D_VSCRADD, ((par->scroll_pos) >> 8) & 0xFF, (par->scroll_pos) & 0xFF);
}

static struct fbtft_display display = {
.regwidth = 8,
.width = WIDTH,
Expand All @@ -195,6 +205,7 @@ static struct fbtft_display display = {
.init_display = init_display,
.set_addr_win = set_addr_win,
.set_var = set_var,
.set_scroll = set_scroll,
},
};

Expand Down
3 changes: 3 additions & 0 deletions drivers/staging/fbtft/fb_hx8357d.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
#define HX8357_TFTWIDTH 320
#define HX8357_TFTHEIGHT 480

#define HX8357D_VSCRDEF 0x33
#define HX8357D_VSCRADD 0x37

#define HX8357_SETOSC 0xB0
#define HX8357_SETPWR1 0xB1
#define HX8357B_SETDISPLAY 0xB2
Expand Down
8 changes: 8 additions & 0 deletions drivers/staging/fbtft/fbtft-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,11 @@ static void fbtft_update_display(struct fbtft_par *par, unsigned int start_line,
}
}

if (par->fbtftops.set_scroll)
{
par->fbtftops.set_scroll(par);
}

/* Sanity checks */
if (start_line > end_line) {
dev_warn(par->info->device,
Expand Down Expand Up @@ -623,6 +628,9 @@ static void fbtft_merge_fbtftops(struct fbtft_ops *dst, struct fbtft_ops *src)
dst->set_var = src->set_var;
if (src->set_gamma)
dst->set_gamma = src->set_gamma;
if (src->set_scroll)
dst->set_scroll = src->set_scroll;

}

/**
Expand Down
39 changes: 39 additions & 0 deletions drivers/staging/fbtft/fbtft-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,55 @@ static ssize_t show_debug(struct device *device,
static struct device_attribute debug_device_attr = \
__ATTR(debug, 0660, show_debug, store_debug);



static ssize_t store_scroll(struct device *device,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct fb_info *fb_info = dev_get_drvdata(device);
struct fbtft_par *par = fb_info->par;
int ret;

ret = kstrtoul(buf, 10, &par->scroll_pos);

if (ret)
return ret;

// if (par->fbtftops.set_scroll)
// par->fbtftops.set_scroll(par);


return count;
}

static ssize_t show_scroll(struct device *device,
struct device_attribute *attr, char *buf)
{
struct fb_info *fb_info = dev_get_drvdata(device);
struct fbtft_par *par = fb_info->par;

return snprintf(buf, PAGE_SIZE, "%lu\n", par->scroll_pos);
}

static struct device_attribute scroll_pos_device_attr = \
__ATTR(scroll_pos, 0660, show_scroll, store_scroll);


void fbtft_sysfs_init(struct fbtft_par *par)
{
device_create_file(par->info->dev, &debug_device_attr);
if (par->fbtftops.set_scroll)
device_create_file(par->info->dev, &scroll_pos_device_attr);
if (par->gamma.curves && par->fbtftops.set_gamma)
device_create_file(par->info->dev, &gamma_device_attrs[0]);
}

void fbtft_sysfs_exit(struct fbtft_par *par)
{
device_remove_file(par->info->dev, &debug_device_attr);
if (par->fbtftops.set_scroll)
device_remove_file(par->info->dev, &scroll_pos_device_attr);
if (par->gamma.curves && par->fbtftops.set_gamma)
device_remove_file(par->info->dev, &gamma_device_attrs[0]);
}
2 changes: 2 additions & 0 deletions drivers/staging/fbtft/fbtft.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ struct fbtft_ops {

int (*set_var)(struct fbtft_par *par);
int (*set_gamma)(struct fbtft_par *par, unsigned long *curves);
void (*set_scroll)(struct fbtft_par *par);
};

/**
Expand Down Expand Up @@ -240,6 +241,7 @@ struct fbtft_par {
bool first_update_done;
ktime_t update_time;
bool bgr;
unsigned long scroll_pos;
void *extra;
};

Expand Down