s5p_mfc_opr.h revision 2c3fb08b3f74b8792004095a1f6881a3296ff643
1/*
2 * drivers/media/platform/samsung/mfc5/s5p_mfc_opr.h
3 *
4 * Header file for Samsung MFC (Multi Function Codec - FIMV) driver
5 * Contains declarations of hw related functions.
6 *
7 * Kamil Debski, Copyright (C) 2011 Samsung Electronics
8 * http://www.samsung.com/
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */
14
15#ifndef S5P_MFC_OPR_H_
16#define S5P_MFC_OPR_H_
17
18#include "s5p_mfc_common.h"
19
20int s5p_mfc_init_decode(struct s5p_mfc_ctx *ctx);
21int s5p_mfc_init_encode(struct s5p_mfc_ctx *mfc_ctx);
22
23/* Decoding functions */
24int s5p_mfc_set_dec_frame_buffer(struct s5p_mfc_ctx *ctx);
25int s5p_mfc_set_dec_stream_buffer(struct s5p_mfc_ctx *ctx, int buf_addr,
26						  unsigned int start_num_byte,
27						  unsigned int buf_size);
28
29/* Encoding functions */
30void s5p_mfc_set_enc_frame_buffer(struct s5p_mfc_ctx *ctx,
31		unsigned long y_addr, unsigned long c_addr);
32int s5p_mfc_set_enc_stream_buffer(struct s5p_mfc_ctx *ctx,
33		unsigned long addr, unsigned int size);
34void s5p_mfc_get_enc_frame_buffer(struct s5p_mfc_ctx *ctx,
35		unsigned long *y_addr, unsigned long *c_addr);
36int s5p_mfc_set_enc_ref_buffer(struct s5p_mfc_ctx *mfc_ctx);
37
38int s5p_mfc_decode_one_frame(struct s5p_mfc_ctx *ctx,
39					enum s5p_mfc_decode_arg last_frame);
40int s5p_mfc_encode_one_frame(struct s5p_mfc_ctx *mfc_ctx);
41
42/* Memory allocation */
43int s5p_mfc_alloc_dec_temp_buffers(struct s5p_mfc_ctx *ctx);
44void s5p_mfc_set_dec_desc_buffer(struct s5p_mfc_ctx *ctx);
45void s5p_mfc_release_dec_desc_buffer(struct s5p_mfc_ctx *ctx);
46
47int s5p_mfc_alloc_codec_buffers(struct s5p_mfc_ctx *ctx);
48void s5p_mfc_release_codec_buffers(struct s5p_mfc_ctx *ctx);
49
50int s5p_mfc_alloc_instance_buffer(struct s5p_mfc_ctx *ctx);
51void s5p_mfc_release_instance_buffer(struct s5p_mfc_ctx *ctx);
52
53void s5p_mfc_try_run(struct s5p_mfc_dev *dev);
54void s5p_mfc_cleanup_queue(struct list_head *lh, struct vb2_queue *vq);
55
56#define s5p_mfc_get_dspl_y_adr()	(readl(dev->regs_base + \
57					S5P_FIMV_SI_DISPLAY_Y_ADR) << \
58					MFC_OFFSET_SHIFT)
59#define s5p_mfc_get_dec_y_adr()		(readl(dev->regs_base + \
60					S5P_FIMV_SI_DECODE_Y_ADR) << \
61					MFC_OFFSET_SHIFT)
62#define s5p_mfc_get_dspl_status()	readl(dev->regs_base + \
63						S5P_FIMV_SI_DISPLAY_STATUS)
64#define s5p_mfc_get_dec_status()	readl(dev->regs_base + \
65						S5P_FIMV_SI_DECODE_STATUS)
66#define s5p_mfc_get_frame_type()	(readl(dev->regs_base + \
67						S5P_FIMV_DECODE_FRAME_TYPE) \
68					& S5P_FIMV_DECODE_FRAME_MASK)
69#define s5p_mfc_get_consumed_stream()	readl(dev->regs_base + \
70						S5P_FIMV_SI_CONSUMED_BYTES)
71#define s5p_mfc_get_int_reason()	(readl(dev->regs_base + \
72					S5P_FIMV_RISC2HOST_CMD) & \
73					S5P_FIMV_RISC2HOST_CMD_MASK)
74#define s5p_mfc_get_int_err()		readl(dev->regs_base + \
75						S5P_FIMV_RISC2HOST_ARG2)
76#define s5p_mfc_err_dec(x)		(((x) & S5P_FIMV_ERR_DEC_MASK) >> \
77							S5P_FIMV_ERR_DEC_SHIFT)
78#define s5p_mfc_err_dspl(x)		(((x) & S5P_FIMV_ERR_DSPL_MASK) >> \
79							S5P_FIMV_ERR_DSPL_SHIFT)
80#define s5p_mfc_get_img_width()		readl(dev->regs_base + \
81						S5P_FIMV_SI_HRESOL)
82#define s5p_mfc_get_img_height()	readl(dev->regs_base + \
83						S5P_FIMV_SI_VRESOL)
84#define s5p_mfc_get_dpb_count()		readl(dev->regs_base + \
85						S5P_FIMV_SI_BUF_NUMBER)
86#define s5p_mfc_get_inst_no()		readl(dev->regs_base + \
87						S5P_FIMV_RISC2HOST_ARG1)
88#define s5p_mfc_get_enc_strm_size()	readl(dev->regs_base + \
89						S5P_FIMV_ENC_SI_STRM_SIZE)
90#define s5p_mfc_get_enc_slice_type()	readl(dev->regs_base + \
91						S5P_FIMV_ENC_SI_SLICE_TYPE)
92
93#endif /* S5P_MFC_OPR_H_ */
94