diff options
author | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2018-05-23 00:12:48 +0200 |
---|---|---|
committer | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2018-05-23 00:18:49 +0200 |
commit | 340435b03e9d73597833e922a736fd7ed61d58ff (patch) | |
tree | 2726b1b9e34748750b8e1a6bc3efb206bbbf58b3 | |
parent | 54b150fc32374921cb583d129c439b5704744dc4 (diff) |
Implement draw_line command
-rw-r--r-- | harddoomdev.c | 73 | ||||
-rw-r--r-- | harddoomdev.h | 9 |
2 files changed, 80 insertions, 2 deletions
diff --git a/harddoomdev.c b/harddoomdev.c index 00ef6f7..e4f6e80 100644 --- a/harddoomdev.c +++ b/harddoomdev.c @@ -4,6 +4,7 @@ #include "doomcode.h" #include "pci.h" #include "private_data.h" +#include "util.h" void doomdev_write(void __iomem *iomem, size_t addr, uint32_t data) { @@ -15,6 +16,73 @@ uint32_t doomdev_read(void __iomem *iomem, size_t addr) return ioread32(iomem + addr); } +void write_command(void __iomem *iomem, uint32_t command) +{ + doomdev_write(iomem, HARDDOOM_FIFO_SEND, command); +} + +void send_command(void __iomem *iomem, uint32_t command) +{ + while (doomdev_read(iomem, HARDDOOM_FIFO_FREE) == 0) {} + + write_command(iomem, command); +} + +uint32_t get_interrupts(void __iomem *iomem) +{ + return doomdev_read(iomem, HARDDOOM_INTR); +} + +void deactivate_intr(void __iomem *iomem, uint32_t intr) +{ + doomdev_write(iomem, HARDDOOM_INTR, intr); +} + +void ping_sync(void __iomem *iomem) +{ + send_command(iomem, HARDDOOM_CMD_PING_SYNC); +} + +void set_surf_dst_pt(void __iomem *iomem, dma_addr_t page_table) +{ + send_command(iomem, HARDDOOM_CMD_SURF_DST_PT(page_table)); +} + +void set_surf_dims(void __iomem *iomem, uint32_t width, uint32_t height) +{ + send_command(iomem, HARDDOOM_CMD_SURF_DIMS(width, height)); +} + +void set_xy_a(void __iomem *iomem, uint16_t x, uint16_t y) +{ + send_command(iomem, HARDDOOM_CMD_XY_A(x, y)); +} + +void set_xy_b(void __iomem *iomem, uint16_t x, uint16_t y) +{ + send_command(iomem, HARDDOOM_CMD_XY_B(x, y)); +} + +void set_fill_color(void __iomem *iomem, uint8_t color) +{ + send_command(iomem, HARDDOOM_CMD_FILL_COLOR(color)); +} + +void draw_line(struct surface_data *surface_data, struct doomdev_line line) +{ + 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, line.pos_a_x, line.pos_a_y); + set_xy_b(iomem, line.pos_b_x, line.pos_b_y); + set_fill_color(iomem, line.color); + + send_command(iomem, HARDDOOM_CMD_DRAW_LINE); +} + uint32_t doomdev_read_stat(void __iomem *iomem, size_t stat) { return doomdev_read(iomem, HARDDOOM_STATS(stat)); @@ -29,7 +97,7 @@ void load_microcode(void __iomem *iomem) doomdev_write(iomem, HARDDOOM_FE_CODE_WINDOW, doomcode[i]); } } - + void start_dev(struct pci_dev *dev) { struct doom_data *data; @@ -40,7 +108,8 @@ void start_dev(struct pci_dev *dev) load_microcode(iomem); doomdev_write(iomem, HARDDOOM_RESET, 0xffffffe); - doomdev_write(iomem, HARDDOOM_INTR, 0x3ff); + doomdev_write(iomem, HARDDOOM_INTR, HARDDOOM_INTR_MASK); + doomdev_write(iomem, HARDDOOM_INTR_ENABLE, HARDDOOM_INTR_MASK); doomdev_write(iomem, HARDDOOM_ENABLE, HARDDOOM_ENABLE_ALL ^ HARDDOOM_ENABLE_FETCH_CMD); } diff --git a/harddoomdev.h b/harddoomdev.h index da8dfe1..a2c997a 100644 --- a/harddoomdev.h +++ b/harddoomdev.h @@ -3,7 +3,16 @@ #include <linux/pci.h> +#include "doomdev.h" +#include "private_data.h" + void start_dev(struct pci_dev *dev); void shutdown_dev(struct pci_dev *dev); +uint32_t get_interrupts(void __iomem *iomem); +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); + #endif |