m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2018-05-23 13:41:01 +0200
committerMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2018-05-23 13:41:01 +0200
commitaaf3b5b832aa1803918aa8653a9e397a7ed3b1e5 (patch)
tree8045d963306c21bb3121353174281d6397330e74
parentd910393a63f610d55c07408fd6f4547b86635988 (diff)
Implement fill rects
-rw-r--r--harddoomdev.c14
-rw-r--r--harddoomdev.h1
-rw-r--r--surface.c24
3 files changed, 39 insertions, 0 deletions
diff --git a/harddoomdev.c b/harddoomdev.c
index e4f6e80..9b327c0 100644
--- a/harddoomdev.c
+++ b/harddoomdev.c
@@ -68,6 +68,20 @@ void set_fill_color(void __iomem *iomem, uint8_t color)
send_command(iomem, HARDDOOM_CMD_FILL_COLOR(color));
}
+void fill_rect(struct surface_data *surface_data, struct doomdev_fill_rect rect)
+{
+ void __iomem *iomem;
+
+ iomem = surface_data->doom_data->iomem;
+
+ set_surf_dst_pt(iomem, surface_data->page_table_dev);
+ set_surf_dims(iomem, surface_data->width, surface_data->height);
+ set_xy_a(iomem, rect.pos_dst_x, rect.pos_dst_y);
+ set_fill_color(iomem, rect.color);
+
+ send_command(iomem, HARDDOOM_CMD_FILL_RECT(rect.width, rect.height));
+}
+
void draw_line(struct surface_data *surface_data, struct doomdev_line line)
{
void __iomem *iomem;
diff --git a/harddoomdev.h b/harddoomdev.h
index a2c997a..05a0b72 100644
--- a/harddoomdev.h
+++ b/harddoomdev.h
@@ -14,5 +14,6 @@ void deactivate_intr(void __iomem *iomem, uint32_t intr);
void ping_sync(void __iomem *iomem);
void draw_line(struct surface_data *surface_data, struct doomdev_line line);
+void fill_rect(struct surface_data *surface_data, struct doomdev_fill_rect rect);
#endif
diff --git a/surface.c b/surface.c
index 27e1eae..d37a468 100644
--- a/surface.c
+++ b/surface.c
@@ -33,11 +33,35 @@ long draw_lines(struct file *filp, unsigned long arg)
return param->lines_num;
}
+long fill_rects(struct file *filp, unsigned long arg)
+{
+ struct surface_data *surface_data;
+ struct doomdev_surf_ioctl_fill_rects *param;
+ struct doomdev_fill_rect *rects;
+ int i;
+
+ surface_data = filp->private_data;
+ param = (struct doomdev_surf_ioctl_fill_rects *) arg;
+ rects = (struct doomdev_fill_rect *) param->rects_ptr;
+
+ mutex_lock(&surface_data->doom_data->cmd_mutex);
+
+ for (i = 0; i < param->rects_num; i++) {
+ fill_rect(surface_data, rects[i]);
+ }
+
+ mutex_unlock(&surface_data->doom_data->cmd_mutex);
+
+ return param->rects_num;
+}
+
long surface_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
switch (cmd) {
case DOOMDEV_SURF_IOCTL_DRAW_LINES:
return draw_lines(filp, arg);
+ case DOOMDEV_SURF_IOCTL_FILL_RECTS:
+ return fill_rects(filp, arg);
default:
return -1;
}