mirror of
https://github.com/hardkernel/kernel_common_drivers.git
synced 2026-06-25 12:03:48 +09:00
gdc: revert the wrong code porting operation [1/1]
PD#SWPL-83878 Problem: dewarp validation for silicon bringup Solution: revert this operation Verify: T7 Signed-off-by: Jian Cao <jian.cao@amlogic.com> Change-Id: I9e9e74c1e93575c99ebad373858519ac0a7c2d63
This commit is contained in:
@@ -19,6 +19,8 @@
|
||||
#include <linux/dma-mapping.h>
|
||||
#include <api/gdc_api.h>
|
||||
#include <linux/dma-map-ops.h>
|
||||
#include <linux/cma.h>
|
||||
#include <linux/kasan.h>
|
||||
|
||||
#include "system_log.h"
|
||||
#include "gdc_dmabuf.h"
|
||||
@@ -98,6 +100,7 @@ static void aml_dma_put(void *buf_priv)
|
||||
{
|
||||
struct aml_dma_buf *buf = buf_priv;
|
||||
struct page *cma_pages = NULL;
|
||||
struct cma *cma_area;
|
||||
void *vaddr = (void *)(PAGE_MASK & (ulong)buf->vaddr);
|
||||
|
||||
if (!atomic_dec_and_test(&buf->refcount)) {
|
||||
@@ -108,10 +111,14 @@ static void aml_dma_put(void *buf_priv)
|
||||
cma_pages = phys_to_page(buf->dma_addr);
|
||||
if (_is_vmalloc_or_module_addr(vaddr))
|
||||
vunmap(vaddr);
|
||||
if (!dma_release_from_contiguous(buf->dev, cma_pages,
|
||||
buf->size >> PAGE_SHIFT)) {
|
||||
/* change in kernel5.15 */
|
||||
if (buf->dev && buf->dev->cma_area)
|
||||
cma_area = buf->dev->cma_area;
|
||||
else
|
||||
cma_area = dma_contiguous_default_area;
|
||||
if (!cma_release(cma_area, cma_pages, buf->size >> PAGE_SHIFT))
|
||||
pr_err("failed to release cma buffer\n");
|
||||
}
|
||||
|
||||
buf->vaddr = NULL;
|
||||
if (buf->index < AML_MAX_DMABUF && buf->priv)
|
||||
clear_dma_buffer((struct aml_dma_buffer *)buf->priv,
|
||||
@@ -130,6 +137,7 @@ static void *aml_dma_alloc(struct device *dev, unsigned long attrs,
|
||||
struct aml_dma_buf *buf;
|
||||
struct page *cma_pages = NULL;
|
||||
dma_addr_t paddr = 0;
|
||||
struct cma *cma_area;
|
||||
|
||||
if (WARN_ON(!dev))
|
||||
return (void *)(-EINVAL);
|
||||
@@ -140,8 +148,13 @@ static void *aml_dma_alloc(struct device *dev, unsigned long attrs,
|
||||
|
||||
if (attrs)
|
||||
buf->attrs = attrs;
|
||||
cma_pages = dma_alloc_from_contiguous(dev,
|
||||
size >> PAGE_SHIFT, 0, 0);
|
||||
|
||||
/* change in kernel5.15 */
|
||||
if (dev && dev->cma_area)
|
||||
cma_area = dev->cma_area;
|
||||
else
|
||||
cma_area = dma_contiguous_default_area;
|
||||
cma_pages = cma_alloc(cma_area, size >> PAGE_SHIFT, 0, 0);
|
||||
if (cma_pages) {
|
||||
paddr = page_to_phys(cma_pages);
|
||||
} else {
|
||||
@@ -312,6 +325,7 @@ static int aml_dmabuf_ops_vmap(struct dma_buf *dbuf, struct dma_buf_map *map)
|
||||
{
|
||||
struct aml_dma_buf *buf = dbuf->priv;
|
||||
|
||||
/* change in kernel5.15 */
|
||||
dma_buf_map_set_vaddr(map, buf->vaddr);
|
||||
return 0;
|
||||
}
|
||||
@@ -327,7 +341,6 @@ static struct dma_buf_ops gdc_dmabuf_ops = {
|
||||
.detach = aml_dmabuf_ops_detach,
|
||||
.map_dma_buf = aml_dmabuf_ops_map,
|
||||
.unmap_dma_buf = aml_dmabuf_ops_unmap,
|
||||
//.kmap_atomic = aml_dmabuf_ops_kmap, // TODO: jian.cao
|
||||
.vmap = aml_dmabuf_ops_vmap,
|
||||
.mmap = aml_dmabuf_ops_mmap,
|
||||
.release = aml_dmabuf_ops_release,
|
||||
|
||||
@@ -14,13 +14,17 @@
|
||||
#include <linux/types.h>
|
||||
#include <linux/clk.h>
|
||||
#include <linux/uaccess.h>
|
||||
#ifdef CONFIG_AMLOGIC_ION
|
||||
#include <dev_ion.h>
|
||||
#endif
|
||||
#include <linux/delay.h>
|
||||
#include <linux/dma-mapping.h>
|
||||
#include <linux/dma-map-ops.h>
|
||||
#include <linux/of_reserved_mem.h>
|
||||
#include <linux/dma-buf.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
#include <linux/cma.h>
|
||||
#include <linux/kasan.h>
|
||||
|
||||
#include <linux/of_address.h>
|
||||
#include <api/gdc_api.h>
|
||||
@@ -38,6 +42,8 @@
|
||||
#include "gdc_dmabuf.h"
|
||||
#include "gdc_wq.h"
|
||||
|
||||
//#define DEBUG
|
||||
|
||||
int gdc_log_level;
|
||||
struct gdc_manager_s gdc_manager;
|
||||
static int kthread_created;
|
||||
@@ -73,6 +79,14 @@ static struct gdc_device_data_s aml_gdc_v2 = {
|
||||
.core_cnt = 3
|
||||
};
|
||||
|
||||
static struct gdc_device_data_s aml_gdc_v3 = {
|
||||
.dev_type = AML_GDC,
|
||||
.clk_type = GATE,
|
||||
.bit_width_ext = 1,
|
||||
.gamma_support = 0,
|
||||
.core_cnt = 1
|
||||
};
|
||||
|
||||
static const struct of_device_id gdc_dt_match[] = {
|
||||
{.compatible = "amlogic, g12b-gdc", .data = &arm_gdc_clk2},
|
||||
{.compatible = "amlogic, arm-gdc", .data = &arm_gdc},
|
||||
@@ -83,6 +97,7 @@ MODULE_DEVICE_TABLE(of, gdc_dt_match);
|
||||
static const struct of_device_id amlgdc_dt_match[] = {
|
||||
{.compatible = "amlogic, aml-gdc", .data = &aml_gdc},
|
||||
{.compatible = "amlogic, aml-gdc-v2", .data = &aml_gdc_v2},
|
||||
{.compatible = "amlogic, aml-gdc-v3", .data = &aml_gdc_v3},
|
||||
{} };
|
||||
|
||||
MODULE_DEVICE_TABLE(of, amlgdc_dt_match);
|
||||
@@ -140,6 +155,7 @@ static int meson_gdc_release(struct inode *inode, struct file *file)
|
||||
bool rc = false;
|
||||
int ret = 0;
|
||||
struct device *dev = NULL;
|
||||
struct cma *cma_area;
|
||||
|
||||
context = (struct gdc_context_s *)file->private_data;
|
||||
if (!context) {
|
||||
@@ -151,8 +167,12 @@ static int meson_gdc_release(struct inode *inode, struct file *file)
|
||||
|
||||
if (context->i_kaddr != 0 && context->i_len != 0) {
|
||||
cma_pages = virt_to_page(context->i_kaddr);
|
||||
rc = dma_release_from_contiguous(dev,
|
||||
cma_pages,
|
||||
/* change in kernel5.15 */
|
||||
if (dev && dev->cma_area)
|
||||
cma_area = dev->cma_area;
|
||||
else
|
||||
cma_area = dma_contiguous_default_area;
|
||||
rc = cma_release(cma_area, cma_pages,
|
||||
context->i_len >> PAGE_SHIFT);
|
||||
if (!rc) {
|
||||
ret = ret - 1;
|
||||
@@ -167,8 +187,11 @@ static int meson_gdc_release(struct inode *inode, struct file *file)
|
||||
|
||||
if (context->o_kaddr != 0 && context->o_len != 0) {
|
||||
cma_pages = virt_to_page(context->o_kaddr);
|
||||
rc = dma_release_from_contiguous(dev,
|
||||
cma_pages,
|
||||
if (dev && dev->cma_area)
|
||||
cma_area = dev->cma_area;
|
||||
else
|
||||
cma_area = dma_contiguous_default_area;
|
||||
rc = cma_release(cma_area, cma_pages,
|
||||
context->o_len >> PAGE_SHIFT);
|
||||
if (!rc) {
|
||||
ret = ret - 1;
|
||||
@@ -183,8 +206,11 @@ static int meson_gdc_release(struct inode *inode, struct file *file)
|
||||
|
||||
if (context->c_kaddr != 0 && context->c_len != 0) {
|
||||
cma_pages = virt_to_page(context->c_kaddr);
|
||||
rc = dma_release_from_contiguous(dev,
|
||||
cma_pages,
|
||||
if (dev && dev->cma_area)
|
||||
cma_area = dev->cma_area;
|
||||
else
|
||||
cma_area = dma_contiguous_default_area;
|
||||
rc = cma_release(cma_area, cma_pages,
|
||||
context->c_len >> PAGE_SHIFT);
|
||||
if (!rc) {
|
||||
ret = ret - 1;
|
||||
@@ -337,10 +363,9 @@ static int meson_gdc_dma_map(struct gdc_dma_cfg *cfg)
|
||||
int ret = -1;
|
||||
int fd = -1;
|
||||
struct dma_buf *dbuf = NULL;
|
||||
struct dma_buf_map map;
|
||||
struct dma_buf_attachment *d_att = NULL;
|
||||
struct sg_table *sg = NULL;
|
||||
void *vaddr = NULL;
|
||||
struct dma_buf_map map;
|
||||
struct device *dev = NULL;
|
||||
enum dma_data_direction dir;
|
||||
|
||||
@@ -377,16 +402,15 @@ static int meson_gdc_dma_map(struct gdc_dma_cfg *cfg)
|
||||
goto access_err;
|
||||
}
|
||||
|
||||
ret = dma_buf_vmap(dbuf, &map);
|
||||
vaddr = ret ? NULL : map.vaddr;
|
||||
if (!vaddr) {
|
||||
ret = dma_buf_vmap(dbuf, &map); //change in kernel5.15 yuhua.lin
|
||||
if (ret) {
|
||||
gdc_log(LOG_ERR, "Failed to vmap dma buf");
|
||||
goto vmap_err;
|
||||
}
|
||||
|
||||
cfg->dbuf = dbuf;
|
||||
cfg->attach = d_att;
|
||||
cfg->vaddr = vaddr;
|
||||
cfg->vaddr = map.vaddr;
|
||||
cfg->sg = sg;
|
||||
|
||||
return ret;
|
||||
@@ -1442,7 +1466,7 @@ static long meson_gdc_ioctl(struct file *file, unsigned int cmd,
|
||||
unsigned long arg)
|
||||
{
|
||||
int ret = -1;
|
||||
size_t len;
|
||||
size_t len = 0;
|
||||
struct gdc_context_s *context = NULL;
|
||||
struct gdc_settings gs;
|
||||
struct gdc_cmd_s *gdc_cmd = NULL;
|
||||
@@ -1453,11 +1477,12 @@ static long meson_gdc_ioctl(struct file *file, unsigned int cmd,
|
||||
struct gdc_settings_with_fw gs_with_fw;
|
||||
struct gdc_dmabuf_req_s gdc_req_buf;
|
||||
struct gdc_dmabuf_exp_s gdc_exp_buf;
|
||||
phys_addr_t addr;
|
||||
phys_addr_t addr = 0;
|
||||
int index, dma_fd;
|
||||
void __user *argp = (void __user *)arg;
|
||||
struct gdc_queue_item_s *pitem = NULL;
|
||||
struct device *dev = NULL;
|
||||
struct cma *cma_area;
|
||||
|
||||
context = (struct gdc_context_s *)file->private_data;
|
||||
gdc_cmd = &context->cmd;
|
||||
@@ -1477,9 +1502,13 @@ static long meson_gdc_ioctl(struct file *file, unsigned int cmd,
|
||||
sizeof(gs), gs.magic);
|
||||
|
||||
//configure gdc config, buffer address and resolution
|
||||
#ifdef CONFIG_AMLOGIC_ION
|
||||
ret = meson_ion_share_fd_to_phys(gs.out_fd,
|
||||
&addr,
|
||||
&len);
|
||||
#else
|
||||
ret = -1;
|
||||
#endif
|
||||
if (ret < 0) {
|
||||
gdc_log(LOG_ERR,
|
||||
"import out fd %d failed\n", gs.out_fd);
|
||||
@@ -1494,9 +1523,13 @@ static long meson_gdc_ioctl(struct file *file, unsigned int cmd,
|
||||
gdc_cmd->base_gdc = 0;
|
||||
gdc_cmd->current_addr = gdc_cmd->buffer_addr;
|
||||
|
||||
#ifdef CONFIG_AMLOGIC_ION
|
||||
ret = meson_ion_share_fd_to_phys(gc->config_addr,
|
||||
&addr,
|
||||
&len);
|
||||
#else
|
||||
ret = -1;
|
||||
#endif
|
||||
if (ret < 0) {
|
||||
gdc_log(LOG_ERR, "import config fd failed\n");
|
||||
mutex_unlock(&context->d_mutext);
|
||||
@@ -1505,9 +1538,13 @@ static long meson_gdc_ioctl(struct file *file, unsigned int cmd,
|
||||
|
||||
gc->config_addr = addr;
|
||||
|
||||
#ifdef CONFIG_AMLOGIC_ION
|
||||
ret = meson_ion_share_fd_to_phys(gs.in_fd,
|
||||
&addr,
|
||||
&len);
|
||||
#else
|
||||
ret = -1;
|
||||
#endif
|
||||
if (ret < 0) {
|
||||
gdc_log(LOG_ERR, "import in fd %d failed\n", gs.in_fd);
|
||||
mutex_unlock(&context->d_mutext);
|
||||
@@ -1619,18 +1656,18 @@ static long meson_gdc_ioctl(struct file *file, unsigned int cmd,
|
||||
}
|
||||
|
||||
buf_cfg.len = PAGE_ALIGN(buf_cfg.len);
|
||||
cma_pages = dma_alloc_from_contiguous
|
||||
(dev,
|
||||
buf_cfg.len >> PAGE_SHIFT,
|
||||
0, 0);
|
||||
if (!cma_pages) {
|
||||
/* change in kernel5.15 */
|
||||
if (dev && dev->cma_area)
|
||||
cma_area = dev->cma_area;
|
||||
else
|
||||
cma_area = dma_contiguous_default_area;
|
||||
cma_pages = cma_alloc(cma_area, buf_cfg.len >> PAGE_SHIFT, 0, 0);
|
||||
if (cma_pages) {
|
||||
context->mmap_type = buf_cfg.type;
|
||||
ret = meson_gdc_set_buff(context,
|
||||
cma_pages, buf_cfg.len);
|
||||
if (ret != 0) {
|
||||
dma_release_from_contiguous
|
||||
(dev,
|
||||
cma_pages,
|
||||
cma_release(cma_area, cma_pages,
|
||||
buf_cfg.len >> PAGE_SHIFT);
|
||||
gdc_log(LOG_ERR, "Failed to set buff\n");
|
||||
return ret;
|
||||
@@ -1810,7 +1847,7 @@ static ssize_t dump_reg_store(struct device *dev,
|
||||
|
||||
ret = kstrtoint(buf, 0, &res);
|
||||
|
||||
pr_info("dump mode: %d->%d\n", gdc_dev->reg_store_mode_enable, res);
|
||||
pr_debug("dump mode: %d->%d\n", gdc_dev->reg_store_mode_enable, res);
|
||||
gdc_dev->reg_store_mode_enable = res;
|
||||
|
||||
return len;
|
||||
@@ -1834,7 +1871,7 @@ static ssize_t loglevel_store(struct device *dev,
|
||||
int ret = 0;
|
||||
|
||||
ret = kstrtoint(buf, 0, &res);
|
||||
pr_info("log_level: %d->%d\n", gdc_log_level, res);
|
||||
pr_debug("log_level: %d->%d\n", gdc_log_level, res);
|
||||
gdc_log_level = res;
|
||||
|
||||
return len;
|
||||
@@ -1863,7 +1900,7 @@ static ssize_t trace_mode_store(struct device *dev,
|
||||
(struct meson_gdc_dev_t *)dev_get_drvdata(dev);
|
||||
|
||||
ret = kstrtoint(buf, 0, &res);
|
||||
pr_info("trace_mode: %d->%d\n", gdc_dev->trace_mode_enable, res);
|
||||
pr_debug("trace_mode: %d->%d\n", gdc_dev->trace_mode_enable, res);
|
||||
gdc_dev->trace_mode_enable = res;
|
||||
|
||||
return len;
|
||||
@@ -1894,11 +1931,11 @@ static ssize_t config_out_path_store(struct device *dev,
|
||||
(struct meson_gdc_dev_t *)dev_get_drvdata(dev);
|
||||
|
||||
if (strlen(buf) >= CONFIG_PATH_LENG) {
|
||||
pr_info("err: path too long\n");
|
||||
pr_err("err: path too long\n");
|
||||
} else {
|
||||
strncpy(gdc_dev->config_out_file, buf, CONFIG_PATH_LENG - 1);
|
||||
gdc_dev->config_out_path_defined = 1;
|
||||
pr_info("set config out path: %s\n", gdc_dev->config_out_file);
|
||||
pr_debug("set config out path: %s\n", gdc_dev->config_out_file);
|
||||
}
|
||||
|
||||
return len;
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include <linux/types.h>
|
||||
#include <linux/clk.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <dev_ion.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/dma-mapping.h>
|
||||
#include <linux/dma-map-ops.h>
|
||||
@@ -79,35 +78,8 @@ void gdc_unmap_virt_from_phys(u8 __iomem *vaddr)
|
||||
|
||||
static int write_buf_to_file(char *path, char *buf, int size)
|
||||
{
|
||||
#ifdef CONFIG_AMLOGIC_ENABLE_MEDIA_FILE
|
||||
int ret = 0;
|
||||
struct file *fp = NULL;
|
||||
loff_t pos = 0;
|
||||
int w_size = 0;
|
||||
|
||||
if (!path) {
|
||||
gdc_log(LOG_ERR, "please define path first\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* open file to write */
|
||||
fp = filp_open(path, O_WRONLY | O_CREAT, 0640);
|
||||
if (IS_ERR(fp)) {
|
||||
gdc_log(LOG_ERR, "open file error\n");
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
/* Write buf to file */
|
||||
w_size = vfs_write(fp, buf, size, &pos);
|
||||
gdc_log(LOG_DEBUG, "write w_size = %u, size = %u\n", w_size, size);
|
||||
|
||||
vfs_fsync(fp, 0);
|
||||
filp_close(fp, NULL);
|
||||
|
||||
return w_size;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
gdc_log(LOG_ERR, "%s has not been supported\n", __func__);
|
||||
return size;
|
||||
}
|
||||
|
||||
void dump_config_file(struct gdc_config_s *gc, u32 dev_type)
|
||||
|
||||
Reference in New Issue
Block a user