blob: 49625c4eaf4cc464479e8eff92e1ca295a4b60df [file] [log] [blame]
Duy Truong790f06d2013-02-13 16:38:12 -08001/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
Mingcheng Zhu9812bd32011-07-22 22:57:11 -07002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * helper functions for physically contiguous PMEM capture buffers
13 */
14
15#ifndef _VIDEOBUF2_PMEM_CONTIG_H
16#define _VIDEOBUF2_PMEM_CONTIG_H
17
18#include <media/videobuf2-core.h>
Laura Abbott5b1e6f12012-05-28 08:13:55 -070019#include <mach/iommu_domains.h>
Mitchel Humpherys252fa6a2012-09-06 10:28:47 -070020#include <linux/msm_ion.h>
Mingcheng Zhu9812bd32011-07-22 22:57:11 -070021
22struct videobuf2_mapping {
23 unsigned int count;
24};
25
Kiran Kumar H N5e08d772011-10-03 10:19:15 -070026enum videobuf2_buffer_type {
27 VIDEOBUF2_SINGLE_PLANE,
28 VIDEOBUF2_MULTIPLE_PLANES
29};
30
31struct videobuf2_sp_offset {
32 uint32_t y_off;
33 uint32_t cbcr_off;
34};
35
36struct videobuf2_msm_offset {
37 union {
38 struct videobuf2_sp_offset sp_off;
39 uint32_t data_offset;
40 };
41};
42
Mingcheng Zhu9812bd32011-07-22 22:57:11 -070043struct videobuf2_contig_pmem {
44 u32 magic;
45 void *vaddr;
46 int phyaddr;
47 unsigned long size;
48 int is_userptr;
Kiran Kumar H N5e08d772011-10-03 10:19:15 -070049 /* Offset of the plane inside the buffer */
50 struct videobuf2_msm_offset offset;
51 enum videobuf2_buffer_type buffer_type;
52 int path;
Mingcheng Zhu9812bd32011-07-22 22:57:11 -070053 struct file *file;
Kiran Kumar H N5e08d772011-10-03 10:19:15 -070054 /* Offset of the buffer */
Mingcheng Zhu9812bd32011-07-22 22:57:11 -070055 uint32_t addr_offset;
56 int dirty;
57 unsigned int count;
58 void *alloc_ctx;
Kiran Kumar H Nceea7622011-08-23 14:01:03 -070059 unsigned long mapped_phyaddr;
Ankit Premrajka748a70a2011-11-01 08:22:04 -070060 struct ion_handle *ion_handle;
Ankit Premrajkad8147432012-01-06 09:45:11 -080061 struct ion_client *client;
Mingcheng Zhu9812bd32011-07-22 22:57:11 -070062};
63void videobuf2_queue_pmem_contig_init(struct vb2_queue *q,
64 enum v4l2_buf_type type,
65 const struct vb2_ops *ops,
66 unsigned int size,
67 void *priv);
68int videobuf2_pmem_contig_mmap_get(struct videobuf2_contig_pmem *mem,
Kiran Kumar H N5e08d772011-10-03 10:19:15 -070069 struct videobuf2_msm_offset *offset,
70 enum videobuf2_buffer_type, int path);
Mingcheng Zhu9812bd32011-07-22 22:57:11 -070071int videobuf2_pmem_contig_user_get(struct videobuf2_contig_pmem *mem,
Kiran Kumar H N5e08d772011-10-03 10:19:15 -070072 struct videobuf2_msm_offset *offset,
73 enum videobuf2_buffer_type,
Ankit Premrajka748a70a2011-11-01 08:22:04 -070074 uint32_t addr_offset, int path,
Ankit Premrajka79b9f222012-07-02 12:38:34 -070075 struct ion_client *client,
76 int domain_num);
Ankit Premrajka748a70a2011-11-01 08:22:04 -070077void videobuf2_pmem_contig_user_put(struct videobuf2_contig_pmem *mem,
Ankit Premrajka79b9f222012-07-02 12:38:34 -070078 struct ion_client *client, int domain_num);
Ankit Premrajkac6864b82011-07-15 11:43:41 -070079unsigned long videobuf2_to_pmem_contig(struct vb2_buffer *buf,
80 unsigned int plane_no);
Mingcheng Zhu9812bd32011-07-22 22:57:11 -070081
82#endif /* _VIDEOBUF2_PMEM_CONTIG_H */