jpeg-hw-s5p.c revision bb677f3ac434cb1708938f1e76a41d9098affd05
1bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz/* linux/drivers/media/video/s5p-jpeg/jpeg-hw.h 2bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * 3bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * Copyright (c) 2011 Samsung Electronics Co., Ltd. 4bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * http://www.samsung.com 5bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * 6bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> 7bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * 8bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * This program is free software; you can redistribute it and/or modify 9bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * it under the terms of the GNU General Public License version 2 as 10bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * published by the Free Software Foundation. 11bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz */ 12bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#ifndef JPEG_HW_H_ 13bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define JPEG_HW_H_ 14bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 15bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#include <linux/io.h> 16bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 17bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#include "jpeg-hw.h" 18bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#include "jpeg-regs.h" 19bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 20bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define S5P_JPEG_MIN_WIDTH 32 21bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define S5P_JPEG_MIN_HEIGHT 32 22bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define S5P_JPEG_MAX_WIDTH 8192 23bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define S5P_JPEG_MAX_HEIGHT 8192 24bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define S5P_JPEG_ENCODE 0 25bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define S5P_JPEG_DECODE 1 26bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define S5P_JPEG_RAW_IN_565 0 27bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define S5P_JPEG_RAW_IN_422 1 28bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define S5P_JPEG_SUBSAMPLING_422 0 29bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define S5P_JPEG_SUBSAMPLING_420 1 30bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define S5P_JPEG_RAW_OUT_422 0 31bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define S5P_JPEG_RAW_OUT_420 1 32bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 33bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstatic inline void jpeg_reset(void __iomem *regs) 34bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz{ 35bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz unsigned long reg; 36bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 37bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz writel(1, regs + S5P_JPG_SW_RESET); 38bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg = readl(regs + S5P_JPG_SW_RESET); 39bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz /* no other way but polling for when JPEG IP becomes operational */ 40bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz while (reg != 0) { 41bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz cpu_relax(); 42bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg = readl(regs + S5P_JPG_SW_RESET); 43bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz } 44bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz} 45bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 46bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstatic inline void jpeg_poweron(void __iomem *regs) 47bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz{ 48bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz writel(S5P_POWER_ON, regs + S5P_JPGCLKCON); 49bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz} 50bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 51bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstatic inline void jpeg_input_raw_mode(void __iomem *regs, unsigned long mode) 52bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz{ 53bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz unsigned long reg, m; 54bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 55bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz m = S5P_MOD_SEL_565; 56bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz if (mode == S5P_JPEG_RAW_IN_565) 57bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz m = S5P_MOD_SEL_565; 58bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz else if (mode == S5P_JPEG_RAW_IN_422) 59bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz m = S5P_MOD_SEL_422; 60bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 61bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg = readl(regs + S5P_JPGCMOD); 62bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg &= ~S5P_MOD_SEL_MASK; 63bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg |= m; 64bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz writel(reg, regs + S5P_JPGCMOD); 65bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz} 66bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 67bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstatic inline void jpeg_input_raw_y16(void __iomem *regs, bool y16) 68bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz{ 69bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz unsigned long reg; 70bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 71bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg = readl(regs + S5P_JPGCMOD); 72bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz if (y16) 73bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg |= S5P_MODE_Y16; 74bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz else 75bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg &= ~S5P_MODE_Y16_MASK; 76bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz writel(reg, regs + S5P_JPGCMOD); 77bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz} 78bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 79bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstatic inline void jpeg_proc_mode(void __iomem *regs, unsigned long mode) 80bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz{ 81bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz unsigned long reg, m; 82bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 83bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz m = S5P_PROC_MODE_DECOMPR; 84bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz if (mode == S5P_JPEG_ENCODE) 85bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz m = S5P_PROC_MODE_COMPR; 86bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz else 87bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz m = S5P_PROC_MODE_DECOMPR; 88bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg = readl(regs + S5P_JPGMOD); 89bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg &= ~S5P_PROC_MODE_MASK; 90bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg |= m; 91bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz writel(reg, regs + S5P_JPGMOD); 92bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz} 93bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 94bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstatic inline void jpeg_subsampling_mode(void __iomem *regs, unsigned long mode) 95bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz{ 96bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz unsigned long reg, m; 97bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 98bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz m = S5P_SUBSAMPLING_MODE_422; 99bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz if (mode == S5P_JPEG_SUBSAMPLING_422) 100bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz m = S5P_SUBSAMPLING_MODE_422; 101bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz else if (mode == S5P_JPEG_SUBSAMPLING_420) 102bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz m = S5P_SUBSAMPLING_MODE_420; 103bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg = readl(regs + S5P_JPGMOD); 104bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg &= ~S5P_SUBSAMPLING_MODE_MASK; 105bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg |= m; 106bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz writel(reg, regs + S5P_JPGMOD); 107bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz} 108bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 109bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstatic inline void jpeg_dri(void __iomem *regs, unsigned int dri) 110bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz{ 111bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz unsigned long reg; 112bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 113bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg = readl(regs + S5P_JPGDRI_U); 114bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg &= ~0xff; 115bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg |= (dri >> 8) & 0xff; 116bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz writel(reg, regs + S5P_JPGDRI_U); 117bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 118bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg = readl(regs + S5P_JPGDRI_L); 119bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg &= ~0xff; 120bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg |= dri & 0xff; 121bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz writel(reg, regs + S5P_JPGDRI_L); 122bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz} 123bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 124bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstatic inline void jpeg_qtbl(void __iomem *regs, unsigned int t, unsigned int n) 125bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz{ 126bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz unsigned long reg; 127bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 128bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg = readl(regs + S5P_JPG_QTBL); 129bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg &= ~S5P_QT_NUMt_MASK(t); 130bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg |= (n << S5P_QT_NUMt_SHIFT(t)) & S5P_QT_NUMt_MASK(t); 131bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz writel(reg, regs + S5P_JPG_QTBL); 132bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz} 133bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 134bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstatic inline void jpeg_htbl_ac(void __iomem *regs, unsigned int t) 135bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz{ 136bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz unsigned long reg; 137bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 138bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg = readl(regs + S5P_JPG_HTBL); 139bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg &= ~S5P_HT_NUMt_AC_MASK(t); 140bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz /* this driver uses table 0 for all color components */ 141bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg |= (0 << S5P_HT_NUMt_AC_SHIFT(t)) & S5P_HT_NUMt_AC_MASK(t); 142bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz writel(reg, regs + S5P_JPG_HTBL); 143bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz} 144bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 145bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstatic inline void jpeg_htbl_dc(void __iomem *regs, unsigned int t) 146bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz{ 147bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz unsigned long reg; 148bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 149bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg = readl(regs + S5P_JPG_HTBL); 150bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg &= ~S5P_HT_NUMt_DC_MASK(t); 151bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz /* this driver uses table 0 for all color components */ 152bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg |= (0 << S5P_HT_NUMt_DC_SHIFT(t)) & S5P_HT_NUMt_DC_MASK(t); 153bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz writel(reg, regs + S5P_JPG_HTBL); 154bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz} 155bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 156bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstatic inline void jpeg_y(void __iomem *regs, unsigned int y) 157bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz{ 158bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz unsigned long reg; 159bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 160bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg = readl(regs + S5P_JPGY_U); 161bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg &= ~0xff; 162bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg |= (y >> 8) & 0xff; 163bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz writel(reg, regs + S5P_JPGY_U); 164bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 165bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg = readl(regs + S5P_JPGY_L); 166bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg &= ~0xff; 167bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg |= y & 0xff; 168bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz writel(reg, regs + S5P_JPGY_L); 169bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz} 170bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 171bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstatic inline void jpeg_x(void __iomem *regs, unsigned int x) 172bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz{ 173bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz unsigned long reg; 174bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 175bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg = readl(regs + S5P_JPGX_U); 176bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg &= ~0xff; 177bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg |= (x >> 8) & 0xff; 178bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz writel(reg, regs + S5P_JPGX_U); 179bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 180bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg = readl(regs + S5P_JPGX_L); 181bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg &= ~0xff; 182bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg |= x & 0xff; 183bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz writel(reg, regs + S5P_JPGX_L); 184bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz} 185bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 186bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstatic inline void jpeg_rst_int_enable(void __iomem *regs, bool enable) 187bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz{ 188bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz unsigned long reg; 189bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 190bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg = readl(regs + S5P_JPGINTSE); 191bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg &= ~S5P_RSTm_INT_EN_MASK; 192bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz if (enable) 193bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg |= S5P_RSTm_INT_EN; 194bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz writel(reg, regs + S5P_JPGINTSE); 195bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz} 196bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 197bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstatic inline void jpeg_data_num_int_enable(void __iomem *regs, bool enable) 198bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz{ 199bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz unsigned long reg; 200bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 201bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg = readl(regs + S5P_JPGINTSE); 202bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg &= ~S5P_DATA_NUM_INT_EN_MASK; 203bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz if (enable) 204bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg |= S5P_DATA_NUM_INT_EN; 205bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz writel(reg, regs + S5P_JPGINTSE); 206bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz} 207bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 208bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstatic inline void jpeg_final_mcu_num_int_enable(void __iomem *regs, bool enbl) 209bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz{ 210bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz unsigned long reg; 211bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 212bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg = readl(regs + S5P_JPGINTSE); 213bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg &= ~S5P_FINAL_MCU_NUM_INT_EN_MASK; 214bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz if (enbl) 215bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg |= S5P_FINAL_MCU_NUM_INT_EN; 216bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz writel(reg, regs + S5P_JPGINTSE); 217bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz} 218bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 219bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstatic inline void jpeg_timer_enable(void __iomem *regs, unsigned long val) 220bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz{ 221bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz unsigned long reg; 222bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 223bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg = readl(regs + S5P_JPG_TIMER_SE); 224bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg |= S5P_TIMER_INT_EN; 225bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg &= ~S5P_TIMER_INIT_MASK; 226bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg |= val & S5P_TIMER_INIT_MASK; 227bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz writel(reg, regs + S5P_JPG_TIMER_SE); 228bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz} 229bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 230bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstatic inline void jpeg_timer_disable(void __iomem *regs) 231bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz{ 232bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz unsigned long reg; 233bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 234bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg = readl(regs + S5P_JPG_TIMER_SE); 235bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg &= ~S5P_TIMER_INT_EN_MASK; 236bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz writel(reg, regs + S5P_JPG_TIMER_SE); 237bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz} 238bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 239bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstatic inline int jpeg_timer_stat(void __iomem *regs) 240bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz{ 241bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz return (int)((readl(regs + S5P_JPG_TIMER_ST) & S5P_TIMER_INT_STAT_MASK) 242bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz >> S5P_TIMER_INT_STAT_SHIFT); 243bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz} 244bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 245bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstatic inline void jpeg_clear_timer_stat(void __iomem *regs) 246bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz{ 247bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz unsigned long reg; 248bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 249bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg = readl(regs + S5P_JPG_TIMER_SE); 250bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg &= ~S5P_TIMER_INT_STAT_MASK; 251bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz writel(reg, regs + S5P_JPG_TIMER_SE); 252bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz} 253bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 254bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstatic inline void jpeg_enc_stream_int(void __iomem *regs, unsigned long size) 255bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz{ 256bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz unsigned long reg; 257bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 258bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg = readl(regs + S5P_JPG_ENC_STREAM_INTSE); 259bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg &= ~S5P_ENC_STREAM_BOUND_MASK; 260bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg |= S5P_ENC_STREAM_INT_EN; 261bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg |= size & S5P_ENC_STREAM_BOUND_MASK; 262bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz writel(reg, regs + S5P_JPG_ENC_STREAM_INTSE); 263bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz} 264bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 265bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstatic inline int jpeg_enc_stream_stat(void __iomem *regs) 266bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz{ 267bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz return (int)(readl(regs + S5P_JPG_ENC_STREAM_INTST) & 268bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz S5P_ENC_STREAM_INT_STAT_MASK); 269bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz} 270bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 271bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstatic inline void jpeg_clear_enc_stream_stat(void __iomem *regs) 272bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz{ 273bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz unsigned long reg; 274bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 275bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg = readl(regs + S5P_JPG_ENC_STREAM_INTSE); 276bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg &= ~S5P_ENC_STREAM_INT_MASK; 277bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz writel(reg, regs + S5P_JPG_ENC_STREAM_INTSE); 278bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz} 279bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 280bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstatic inline void jpeg_outform_raw(void __iomem *regs, unsigned long format) 281bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz{ 282bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz unsigned long reg, f; 283bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 284bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz f = S5P_DEC_OUT_FORMAT_422; 285bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz if (format == S5P_JPEG_RAW_OUT_422) 286bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz f = S5P_DEC_OUT_FORMAT_422; 287bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz else if (format == S5P_JPEG_RAW_OUT_420) 288bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz f = S5P_DEC_OUT_FORMAT_420; 289bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg = readl(regs + S5P_JPG_OUTFORM); 290bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg &= ~S5P_DEC_OUT_FORMAT_MASK; 291bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg |= f; 292bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz writel(reg, regs + S5P_JPG_OUTFORM); 293bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz} 294bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 295bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstatic inline void jpeg_jpgadr(void __iomem *regs, unsigned long addr) 296bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz{ 297bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz writel(addr, regs + S5P_JPG_JPGADR); 298bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz} 299bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 300bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstatic inline void jpeg_imgadr(void __iomem *regs, unsigned long addr) 301bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz{ 302bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz writel(addr, regs + S5P_JPG_IMGADR); 303bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz} 304bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 305bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstatic inline void jpeg_coef(void __iomem *regs, unsigned int i, 306bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz unsigned int j, unsigned int coef) 307bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz{ 308bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz unsigned long reg; 309bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 310bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg = readl(regs + S5P_JPG_COEF(i)); 311bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg &= ~S5P_COEFn_MASK(j); 312bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg |= (coef << S5P_COEFn_SHIFT(j)) & S5P_COEFn_MASK(j); 313bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz writel(reg, regs + S5P_JPG_COEF(i)); 314bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz} 315bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 316bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstatic inline void jpeg_start(void __iomem *regs) 317bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz{ 318bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz writel(1, regs + S5P_JSTART); 319bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz} 320bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 321bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstatic inline int jpeg_result_stat_ok(void __iomem *regs) 322bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz{ 323bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz return (int)((readl(regs + S5P_JPGINTST) & S5P_RESULT_STAT_MASK) 324bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz >> S5P_RESULT_STAT_SHIFT); 325bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz} 326bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 327bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstatic inline int jpeg_stream_stat_ok(void __iomem *regs) 328bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz{ 329bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz return !(int)((readl(regs + S5P_JPGINTST) & S5P_STREAM_STAT_MASK) 330bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz >> S5P_STREAM_STAT_SHIFT); 331bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz} 332bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 333bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstatic inline void jpeg_clear_int(void __iomem *regs) 334bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz{ 335bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz unsigned long reg; 336bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 337bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg = readl(regs + S5P_JPGINTST); 338bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz writel(S5P_INT_RELEASE, regs + S5P_JPGCOM); 339bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz reg = readl(regs + S5P_JPGOPR); 340bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz} 341bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 342bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstatic inline unsigned int jpeg_compressed_size(void __iomem *regs) 343bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz{ 344bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz unsigned long jpeg_size = 0; 345bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 346bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz jpeg_size |= (readl(regs + S5P_JPGCNT_U) & 0xff) << 16; 347bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz jpeg_size |= (readl(regs + S5P_JPGCNT_M) & 0xff) << 8; 348bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz jpeg_size |= (readl(regs + S5P_JPGCNT_L) & 0xff); 349bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 350bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz return (unsigned int)jpeg_size; 351bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz} 352bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 353bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#endif /* JPEG_HW_H_ */ 354