1/* 2 * Samsung S5P G2D - 2D Graphics Accelerator Driver 3 * 4 * Copyright (c) 2011 Samsung Electronics Co., Ltd. 5 * Kamil Debski, <k.debski@samsung.com> 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by the 9 * Free Software Foundation; either version 2 of the 10 * License, or (at your option) any later version 11 */ 12 13#include <linux/platform_device.h> 14#include <media/v4l2-device.h> 15#include <media/v4l2-ctrls.h> 16 17#define G2D_NAME "s5p-g2d" 18#define TYPE_G2D_3X 3 19#define TYPE_G2D_4X 4 20 21struct g2d_dev { 22 struct v4l2_device v4l2_dev; 23 struct v4l2_m2m_dev *m2m_dev; 24 struct video_device *vfd; 25 struct mutex mutex; 26 spinlock_t ctrl_lock; 27 atomic_t num_inst; 28 void __iomem *regs; 29 struct clk *clk; 30 struct clk *gate; 31 struct g2d_ctx *curr; 32 struct g2d_variant *variant; 33 int irq; 34 wait_queue_head_t irq_queue; 35}; 36 37struct g2d_frame { 38 /* Original dimensions */ 39 u32 width; 40 u32 height; 41 /* Crop size */ 42 u32 c_width; 43 u32 c_height; 44 /* Offset */ 45 u32 o_width; 46 u32 o_height; 47 /* Image format */ 48 struct g2d_fmt *fmt; 49 /* Variables that can calculated once and reused */ 50 u32 stride; 51 u32 bottom; 52 u32 right; 53 u32 size; 54}; 55 56struct g2d_ctx { 57 struct v4l2_fh fh; 58 struct g2d_dev *dev; 59 struct g2d_frame in; 60 struct g2d_frame out; 61 struct v4l2_ctrl *ctrl_hflip; 62 struct v4l2_ctrl *ctrl_vflip; 63 struct v4l2_ctrl_handler ctrl_handler; 64 u32 rop; 65 u32 flip; 66}; 67 68struct g2d_fmt { 69 char *name; 70 u32 fourcc; 71 int depth; 72 u32 hw; 73}; 74 75struct g2d_variant { 76 unsigned short hw_rev; 77}; 78 79void g2d_reset(struct g2d_dev *d); 80void g2d_set_src_size(struct g2d_dev *d, struct g2d_frame *f); 81void g2d_set_src_addr(struct g2d_dev *d, dma_addr_t a); 82void g2d_set_dst_size(struct g2d_dev *d, struct g2d_frame *f); 83void g2d_set_dst_addr(struct g2d_dev *d, dma_addr_t a); 84void g2d_start(struct g2d_dev *d); 85void g2d_clear_int(struct g2d_dev *d); 86void g2d_set_rop4(struct g2d_dev *d, u32 r); 87void g2d_set_flip(struct g2d_dev *d, u32 r); 88void g2d_set_v41_stretch(struct g2d_dev *d, 89 struct g2d_frame *src, struct g2d_frame *dst); 90void g2d_set_cmd(struct g2d_dev *d, u32 c); 91