F: drivers/amlogic/media/enhancement/amvecm/dnlp_algorithm/*
F: include/linux/amlogic/media/amvecm/*
F: drivers/amlogic/media/enhancement/amvecm/hdr/*
+F: drivers/amlogic/media/enhancement/amvecm/amprime_sl/*
AMLOGIC GXL ADD SKT DTS
M: Yun Cai <yun.cai@amlogic.com>
F: drivers/amlogic/media/enhancement/amdolby_vision*
F: include/linux/amlogic/media/amdolbyvision/*
+AMLOGIC HDR PRIMSE SL DRIVER
+M: Yi Zhou <yi.zhou@amlogic.com>
+F: drivers/amlogic/media/enhancement/amprime_sl/*
+F: include/linux/amlogic/media/amprime_sl/*
+
AMLOGIC G12A Media codec io bus
M: Nanxin Qin <nanxin.qin@amlogic.com>
F: include/linux/amlogic/media/registers/regs/efuse_regs.h
};
};
+ amprime_sl:amprime_sl {
+ compatible = "amlogic, prime_sl_g12";
+ dev_name = "amprime_sl";
+ status = "disabled";
+ };
+
aocec: aocec {
compatible = "amlogic, aocec-g12a";
device_name = "aocec";
};
};
+ amprime_sl:amprime_sl {
+ compatible = "amlogic, prime_sl_g12";
+ dev_name = "amprime_sl";
+ status = "disabled";
+ };
+
galcore {
compatible = "amlogic, galcore";
dev_name = "galcore";
CONFIG_AMLOGIC_MEDIA_ENHANCEMENT=y
CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_VECM=y
CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION=y
+CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_PRIME_SL=y
CONFIG_AMLOGIC_MEDIA_GDC=y
CONFIG_AMLOGIC_VIDEO_CAPTURE=y
CONFIG_AMLOGIC_VM_DISABLE_VIDEOLAYER=y
CONFIG_AMLOGIC_MEDIA_ENHANCEMENT=y
CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_VECM=y
CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION=y
+CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_PRIME_SL=y
CONFIG_AMLOGIC_MMC=y
CONFIG_AMLOGIC_NAND=y
CONFIG_AMLOGIC_VRTC=y
};
};
+ amprime_sl: amprime_sl {
+ compatible = "amlogic, prime_sl_g12";
+ dev_name = "amprime_sl";
+ status = "disabled";
+ };
+
aocec: aocec {
compatible = "amlogic, aocec-g12a";
device_name = "aocec";
};
};
+ amprime_sl: amprime_sl {
+ compatible = "amlogic, prime_sl_g12";
+ dev_name = "amprime_sl";
+ status = "disabled";
+ };
+
galcore {
compatible = "amlogic, galcore";
dev_name = "galcore";
CONFIG_AMLOGIC_MEDIA_ENHANCEMENT=y
CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_VECM=y
CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION=y
+CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_PRIME_SL=y
CONFIG_AMLOGIC_MEDIA_GDC=y
CONFIG_AMLOGIC_VIDEO_CAPTURE=y
CONFIG_AMLOGIC_VM_DISABLE_VIDEOLAYER=y
CONFIG_AMLOGIC_MEDIA_ENHANCEMENT=y
CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_VECM=y
CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION=y
+CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_PRIME_SL=y
CONFIG_AMLOGIC_MMC=y
CONFIG_AMLOGIC_NAND=y
CONFIG_AMLOGIC_VRTC=y
if AMLOGIC_MEDIA_ENHANCEMENT
source "drivers/amlogic/media/enhancement/amvecm/Kconfig"
source "drivers/amlogic/media/enhancement/amdolby_vision/Kconfig"
+source "drivers/amlogic/media/enhancement/amprime_sl/Kconfig"
endif
endmenu
-obj-$(CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_VECM) += amvecm/
-obj-$(CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION) += amdolby_vision/
\ No newline at end of file
+obj-$(CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_VECM) += amvecm/
+obj-$(CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION) += amdolby_vision/
+obj-$(CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_PRIME_SL) += amprime_sl/
--- /dev/null
+#
+# AMLOGIC amprime_sl devices configuration
+#
+
+comment "Amlogic amprime_sl Drivers"
+
+menu "Amlogic amprime_sl Driver"
+
+config AMLOGIC_MEDIA_ENHANCEMENT_PRIME_SL
+ bool "Amlogic amprime_sl driver"
+ default n
+ help
+ "Amlogic amprime_sl module init"
+
+endmenu
--- /dev/null
+#
+# Makefile for amprime_sl
+#
+
+obj-$(CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_PRIME_SL) += amprime_sl.o amprime_sl_hw.o
+
+
--- /dev/null
+/*
+ * drivers/amlogic/media/enhancement/amprime_sl/amprime_sl.c
+ *
+ * Copyright (C) 2017 Amlogic, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ */
+
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/fs.h>
+#include <linux/uaccess.h>
+#include <linux/io.h>
+#include <linux/errno.h>
+#include <linux/dma-mapping.h>
+#include <linux/platform_device.h>
+#include <linux/amlogic/media/vfm/vframe.h>
+#include <linux/amlogic/media/video_sink/video.h>
+#include <linux/amlogic/media/amvecm/amvecm.h>
+#include <linux/amlogic/media/vout/vout_notify.h>
+#include <linux/amlogic/media/vfm/vframe_provider.h>
+#include <linux/amlogic/media/vfm/vframe_receiver.h>
+#include <linux/amlogic/media/utils/amstream.h>
+#include <linux/amlogic/media/registers/regs/viu_regs.h>
+#include <linux/cma.h>
+#include <linux/amlogic/media/codec_mm/codec_mm.h>
+#include <linux/dma-contiguous.h>
+#include <linux/amlogic/iomap.h>
+#include <linux/device.h>
+#include <linux/cdev.h>
+#include <linux/of.h>
+#include <linux/string.h>
+#include <linux/mm.h>
+#include <linux/slab.h>
+#include <linux/stat.h>
+#include <linux/ctype.h>
+#include <linux/string.h>
+#include <linux/vmalloc.h>
+
+#include "amprime_sl.h"
+#include <linux/amlogic/cpu_version.h>
+#include <linux/amlogic/media/amprime_sl/prime_sl.h>
+
+/*======================================*/
+
+static const struct hdr_prime_sl_func_s *p_funcs;
+struct prime_sl_device_data_s prime_sl_meson_dev;
+#define AMPRIME_SL_NAME "amprime_sl"
+#define AMPRIME_SL_CLASS_NAME "amprime_sl"
+
+struct amprime_sl_dev_s {
+ dev_t devt;
+ struct cdev cdev;
+ dev_t devno;
+ struct device *dev;
+ struct class *clsp;
+};
+static struct amprime_sl_dev_s amprime_sl_dev;
+static struct prime_t prime_sl_setting;
+
+static uint prime_sl_enable = DISABLE;
+module_param(prime_sl_enable, uint, 0664);
+MODULE_PARM_DESC(prime_sl_enable, "\n prime_sl_enable\n");
+
+static uint prime_sl_display_Brightness = 150;
+module_param(prime_sl_display_Brightness, uint, 0664);
+MODULE_PARM_DESC(prime_sl_display_Brightness, "\n prime_sl_display_Brightness\n");
+
+bool is_prime_sl_enable(void)
+{
+ return prime_sl_enable;
+}
+EXPORT_SYMBOL(is_prime_sl_enable);
+
+static int parse_para(char *p)
+{
+ int data;
+
+ data = cpu_to_le32((unsigned int)(*p));
+ *p += 4;
+ return data;
+}
+
+static int prime_sl_parse_sei_and_meta(char *p, unsigned int size)
+{
+ unsigned int i;
+ struct sl_hdr_metadata *sl_hdr_metadata
+ = &prime_sl_setting.prime_metadata;
+
+ if (size != sizeof(struct sl_hdr_metadata)) {
+ pr_info("error metadata size\n");
+ return 0;
+ }
+
+ sl_hdr_metadata->partID = parse_para(p);
+ sl_hdr_metadata->majorSpecVersionID = parse_para(p);
+ sl_hdr_metadata->minorSpecVersionID = parse_para(p);
+ sl_hdr_metadata->payloadMode = parse_para(p);
+ sl_hdr_metadata->hdrPicColourSpace = parse_para(p);
+ sl_hdr_metadata->hdrDisplayColourSpace = parse_para(p);
+ sl_hdr_metadata->hdrDisplayMaxLuminance = parse_para(p);
+ sl_hdr_metadata->hdrDisplayMinLuminance = parse_para(p);
+ sl_hdr_metadata->sdrPicColourSpace = parse_para(p);
+ sl_hdr_metadata->sdrDisplayColourSpace = parse_para(p);
+ sl_hdr_metadata->sdrDisplayMaxLuminance = parse_para(p);
+ sl_hdr_metadata->sdrDisplayMinLuminance = parse_para(p);
+ for (i = 0; i < 4; i++)
+ sl_hdr_metadata->matrixCoefficient[i] = parse_para(p);
+ for (i = 0; i < 2; i++)
+ sl_hdr_metadata->chromaToLumaInjection[i] = parse_para(p);
+ for (i = 0; i < 3; i++)
+ sl_hdr_metadata->kCoefficient[i] = parse_para(p);
+ if (!sl_hdr_metadata->payloadMode) {
+ sl_hdr_metadata->u.variables.tmInputSignalBlackLevelOffset
+ = parse_para(p);
+ sl_hdr_metadata->u.variables.tmInputSignalWhiteLevelOffset
+ = parse_para(p);
+ sl_hdr_metadata->u.variables.shadowGain = parse_para(p);
+ sl_hdr_metadata->u.variables.highlightGain = parse_para(p);
+ sl_hdr_metadata->u.variables.midToneWidthAdjFactor
+ = parse_para(p);
+ sl_hdr_metadata->u.variables.tmOutputFineTuningNumVal
+ = parse_para(p);
+ for (i = 0; i < sl_hdr_metadata->
+ u.variables.tmOutputFineTuningNumVal; i++) {
+ sl_hdr_metadata->u.variables.tmOutputFineTuningX[i]
+ = parse_para(p);
+ sl_hdr_metadata->u.variables.tmOutputFineTuningX[i]
+ = parse_para(p);
+ }
+ sl_hdr_metadata->u.variables.saturationGainNumVal
+ = parse_para(p);
+ for (i = 0; i < sl_hdr_metadata->
+ u.variables.saturationGainNumVal; i++) {
+ sl_hdr_metadata->u.variables.saturationGainX[i]
+ = parse_para(p);
+ sl_hdr_metadata->u.variables.saturationGainY[i]
+ = parse_para(p);
+ }
+ } else {
+ sl_hdr_metadata->u.tables.luminanceMappingNumVal
+ = parse_para(p);
+ for (i = 0; i < sl_hdr_metadata->
+ u.tables.luminanceMappingNumVal; i++) {
+ sl_hdr_metadata->u.tables.luminanceMappingX[i]
+ = parse_para(p);
+ sl_hdr_metadata->u.tables.luminanceMappingY[i]
+ = parse_para(p);
+ }
+ sl_hdr_metadata->u.tables.colourCorrectionNumVal
+ = parse_para(p);
+ for (i = 0; i < sl_hdr_metadata->
+ u.tables.colourCorrectionNumVal; i++) {
+ sl_hdr_metadata->u.tables.colourCorrectionX[i]
+ = parse_para(p);
+ sl_hdr_metadata->u.tables.colourCorrectionY[i]
+ = parse_para(p);
+ }
+ }
+ return 0;
+}
+
+static void prime_sl_parser_metadata(struct vframe_s *vf)
+{
+ struct provider_aux_req_s req;
+ struct prime_cfg_t *Cfg = &prime_sl_setting.Cfg;
+ char *p;
+ unsigned int size = 0;
+ unsigned int type = 0;
+
+ if (vf && (vf->source_type == VFRAME_SOURCE_TYPE_OTHERS)) {
+ req.vf = vf;
+ req.bot_flag = 0;
+ req.aux_buf = NULL;
+ req.aux_size = 0;
+ req.dv_enhance_exist = 0;
+ req.low_latency = 0;
+
+ Cfg->width = (vf->type & VIDTYPE_COMPRESS) ?
+ vf->compWidth : vf->width;
+ Cfg->height = (vf->type & VIDTYPE_COMPRESS) ?
+ vf->compHeight : vf->height;
+ Cfg->bit_depth = vf->bitdepth;
+ Cfg->yuv_range = (vf->signal_type >> 25) & 0x1;
+ Cfg->display_Brightness = prime_sl_display_Brightness;
+
+ vf_notify_provider_by_name("prime_sl_dec",
+ VFRAME_EVENT_RECEIVER_GET_AUX_DATA,
+ (void *)&req);
+
+ if (req.aux_buf && req.aux_size) {
+ p = req.aux_buf;
+ while (p < req.aux_buf
+ + req.aux_size - 8) {
+ size = cpu_to_le32((unsigned int)(*p));
+ p += 4;
+ type = cpu_to_le32((unsigned int)(*p));
+ p += 4;
+ if (type == 0x04000000)/*need to double check*/
+ prime_sl_parse_sei_and_meta(p, size);
+ p += size;
+ }
+ }
+ }
+}
+
+void prime_sl_process(struct vframe_s *vf)
+{
+ prime_sl_parser_metadata(vf);
+ if (!p_funcs)
+ p_funcs->prime_metadata_parser_process(&prime_sl_setting);
+ prime_sl_set_reg(&prime_sl_setting.prime_sl);
+ prime_sl_close();
+}
+EXPORT_SYMBOL(prime_sl_process);
+
+static void dbg_setting(struct prime_sl_t *prime_sl)
+{
+ unsigned int i;
+
+ pr_info("%s\n", __func__);
+ pr_info("\t legacy_mode_en\t%d\n", prime_sl->legacy_mode_en);
+ pr_info("\t clip_en\t%d\n", prime_sl->clip_en);
+ pr_info("\t reg_gclk_ctrl\t%d\n", prime_sl->reg_gclk_ctrl);
+ pr_info("\t gclk_ctrl\t%d\n", prime_sl->gclk_ctrl);
+ pr_info("\t primesl_en\t%d\n",
+ prime_sl->primesl_en);
+ pr_info("\t inv_chroma_ratio\t%d\n",
+ prime_sl->inv_chroma_ratio);
+ pr_info("\t inv_y_ratio\t%d\n", prime_sl->inv_y_ratio);
+ pr_info("\t l_headroom\t%d\n", prime_sl->l_headroom);
+ pr_info("\t footroom\t%d\n", prime_sl->footroom);
+ pr_info("\t c_headroom\t%d\n", prime_sl->c_headroom);
+ pr_info("\t mub\t%d\n",
+ prime_sl->mub);
+ pr_info("\t mua\t%d\n", prime_sl->mua);
+
+ for (i = 0; i < 7; i++)
+ pr_info("\t oct[%d]\t%d\n", i, prime_sl->oct[i]);
+ for (i = 0; i < 3; i++)
+ pr_info("\t d_lut_threshold[%d]\t%d\n", i,
+ prime_sl->d_lut_threshold[i]);
+ for (i = 0; i < 4; i++)
+ pr_info("\t d_lut_step[%d]\t%d\n", i, prime_sl->d_lut_step[i]);
+ for (i = 0; i < 9; i++)
+ pr_info("\t rgb2yuv[%d]\t%d\n", i, prime_sl->rgb2yuv[i]);
+ for (i = 0; i < 65; i++)
+ pr_info("\t lut_c[%d]\t%d\n", i, prime_sl->lut_c[i]);
+ for (i = 0; i < 65; i++)
+ pr_info("\t lut_p[%d]\t%d\n", i, prime_sl->lut_p[i]);
+ for (i = 0; i < 65; i++)
+ pr_info("\t lut_d[%d]\t%d\n", i, prime_sl->lut_d[i]);
+}
+
+static void dbg_config(struct prime_cfg_t *Cfg)
+{
+ pr_info("%s\n", __func__);
+
+ pr_info("\t width\t%d\n", Cfg->width);
+ pr_info("\t height\t%d\n", Cfg->height);
+ pr_info("\t bit_depth\t%d\n", Cfg->bit_depth);
+ pr_info("\t display_OETF\t%d\n", Cfg->display_OETF);
+ pr_info("\t display_Brightness\t%d\n",
+ Cfg->display_Brightness);
+ pr_info("\t yuv_range\t%d\n", Cfg->yuv_range);
+}
+
+static void dbg_metadata(struct sl_hdr_metadata *pmetadata)
+{
+ pr_info("%s\n", __func__);
+
+ pr_info("\t partID\t%d\n", pmetadata->partID);
+ pr_info("\t majorSpecVersionID\t%d\n",
+ pmetadata->majorSpecVersionID);
+ pr_info("\t minorSpecVersionID\t%d\n",
+ pmetadata->minorSpecVersionID);
+ pr_info("\t payloadMode\t%d\n",
+ pmetadata->payloadMode);
+ pr_info("\t hdrPicColourSpace\t%d\n",
+ pmetadata->hdrPicColourSpace);
+ pr_info("\t hdrDisplayColourSpace\t%d\n",
+ pmetadata->hdrDisplayColourSpace);
+ pr_info("\t hdrDisplayMaxLuminance\t%d\n",
+ pmetadata->hdrDisplayMaxLuminance);
+
+ pr_info("\t hdrDisplayMinLuminance\t%d\n",
+ pmetadata->hdrDisplayMinLuminance);
+ pr_info("\t sdrPicColourSpace\t%d\n",
+ pmetadata->sdrPicColourSpace);
+ pr_info("\t sdrDisplayColourSpace\t%d\n",
+ pmetadata->sdrDisplayColourSpace);
+ pr_info("\t sdrDisplayMaxLuminance\t%d\n",
+ pmetadata->sdrDisplayMaxLuminance);
+ pr_info("\t sdrDisplayMinLuminance\t%d\n",
+ pmetadata->sdrDisplayMinLuminance);
+
+}
+
+static ssize_t amprime_sl_debug_store(struct class *cla,
+ struct class_attribute *attr,
+ const char *buf, size_t count)
+{
+
+ if (!buf)
+ return count;
+
+ if (!strcmp(buf, "metadata")) {
+ dbg_metadata(&prime_sl_setting.prime_metadata);
+ dbg_config(&prime_sl_setting.Cfg);
+ } else if (!strcmp(buf, "setting"))
+ dbg_setting(&prime_sl_setting.prime_sl);
+ else
+ pr_info("unsupport commands\n");
+ return count;
+
+}
+
+static struct class_attribute amprime_sl_class_attrs[] = {
+ __ATTR(debug, 0644, NULL, amprime_sl_debug_store),
+ __ATTR_NULL
+};
+
+
+int register_prime_functions(const struct hdr_prime_sl_func_s *func)
+{
+ int ret = -1;
+
+ if (!p_funcs && func) {
+ pr_info("*** register_prime_functions. version %s ***\n",
+ func->version_info);
+ ret = 0;
+ p_funcs = func;
+ p_funcs->prime_api_init();
+ }
+ return ret;
+}
+EXPORT_SYMBOL(register_prime_functions);
+
+int unregister_prime_functions(void)
+{
+ int ret = -1;
+
+ if (p_funcs) {
+ pr_info("*** unregister_prime_functions ***\n");
+ p_funcs->prime_api_exit();
+ p_funcs = NULL;
+ ret = 0;
+ }
+ return ret;
+}
+EXPORT_SYMBOL(unregister_prime_functions);
+
+static struct prime_sl_device_data_s prime_sl_g12 = {
+ .cpu_id = _CPU_MAJOR_ID_G12,
+};
+
+static struct prime_sl_device_data_s prime_sl_tl1 = {
+ .cpu_id = _CPU_MAJOR_ID_TL1,
+};
+
+static const struct of_device_id amprime_sl_match[] = {
+ {
+ .compatible = "amlogic, prime_sl_g12",
+ .data = &prime_sl_g12,
+ },
+ {
+ .compatible = "amlogic, prime_sl_tl1",
+ .data = &prime_sl_tl1,
+ },
+ {},
+};
+
+static int amprime_sl_probe(struct platform_device *pdev)
+{
+ int ret = 0;
+ unsigned int i = 0;
+ struct amprime_sl_dev_s *devp = &rime_sl_dev;
+
+ pr_info("amprime_sl probe start & ver: %s\n", DRIVER_VER);
+ if (pdev->dev.of_node) {
+ const struct of_device_id *match;
+ struct prime_sl_device_data_s *prime_sl_meson;
+ struct device_node *of_node = pdev->dev.of_node;
+
+ match = of_match_node(amprime_sl_match, of_node);
+ if (match) {
+ prime_sl_meson =
+ (struct prime_sl_device_data_s *)match->data;
+ if (prime_sl_meson)
+ memcpy(&rime_sl_dev, prime_sl_meson,
+ sizeof(struct prime_sl_device_data_s));
+ else {
+ pr_err("%s data NOT match\n", __func__);
+ return -ENODEV;
+ }
+ } else {
+ pr_err("%s NOT match\n", __func__);
+ return -ENODEV;
+ }
+
+ }
+ pr_info("\n cpu_id=%d\n", prime_sl_meson_dev.cpu_id);
+ memset(devp, 0, (sizeof(struct amprime_sl_dev_s)));
+ ret = alloc_chrdev_region(&devp->devno, 0, 1, AMPRIME_SL_NAME);
+ if (ret < 0)
+ goto fail_alloc_region;
+ devp->clsp = class_create(THIS_MODULE,
+ AMPRIME_SL_CLASS_NAME);
+ if (IS_ERR(devp->clsp)) {
+ ret = PTR_ERR(devp->clsp);
+ goto fail_create_class;
+ }
+
+ for (i = 0; amprime_sl_class_attrs[i].attr.name; i++) {
+ if (class_create_file(devp->clsp,
+ &rime_sl_class_attrs[i]) < 0)
+ goto fail_class_create_file;
+ }
+/* cdev_init(&devp->cdev, &rime_sl_fops);
+ * devp->cdev.owner = THIS_MODULE;
+ * ret = cdev_add(&devp->cdev, devp->devno, 1);
+ * if (ret)
+ * goto fail_add_cdev;
+ *
+ * devp->dev = device_create(devp->clsp, NULL, devp->devno,
+ * NULL, AMPRIME_SL_NAME);
+ * if (IS_ERR(devp->dev)) {
+ * ret = PTR_ERR(devp->dev);
+ * goto fail_create_device;
+ * }
+ */
+ pr_info("%s: probe ok\n", __func__);
+ return 0;
+/*
+ *
+ *fail_create_device:
+ * pr_info("[amprime_sl.] : amprime_sl device create error.\n");
+ * cdev_del(&devp->cdev);
+ *
+ *fail_add_cdev:
+ * pr_info("[amprime_sl.] : amprime_sl add device error.\n");
+ */
+fail_class_create_file:
+ pr_info("[amprime_sl.] : amprime_sl class create file error.\n");
+ for (i = 0; amprime_sl_class_attrs[i].attr.name; i++)
+ class_remove_file(devp->clsp,
+ &rime_sl_class_attrs[i]);
+ class_destroy(devp->clsp);
+fail_create_class:
+ pr_info("[amdolby_vision.] : amdolby_vision class create error.\n");
+ unregister_chrdev_region(devp->devno, 1);
+fail_alloc_region:
+ pr_info("[amprime_sl.] : amprime_sl alloc error.\n");
+ pr_info("[amprime_sl.] : amprime_sl.\n");
+ return ret;
+}
+
+static int __exit amprime_sl_remove(struct platform_device *pdev)
+{
+ struct amprime_sl_dev_s *devp = &rime_sl_dev;
+
+ device_destroy(devp->clsp, devp->devno);
+ cdev_del(&devp->cdev);
+ class_destroy(devp->clsp);
+ unregister_chrdev_region(devp->devno, 1);
+ pr_info("[ amprime_sl.] : amprime_sl.\n");
+ return 0;
+}
+
+static struct platform_driver amprime_sl_driver = {
+ .driver = {
+ .owner = THIS_MODULE,
+ .name = "amprime_sl",
+ .of_match_table = amprime_sl_match,
+ },
+ .probe = amprime_sl_probe,
+ .remove = __exit_p(amprime_sl_remove),
+};
+
+static int __init amprime_sl_init(void)
+{
+ pr_info("prime_sl module init\n");
+ if (platform_driver_register(&rime_sl_driver)) {
+ pr_info("failed to register amprime_sl module\n");
+ return -ENODEV;
+ }
+ return 0;
+}
+
+static void __exit amprime_sl_exit(void)
+{
+ pr_info("prime_sl module exit\n");
+}
+
+module_init(amprime_sl_init);
+module_exit(amprime_sl_exit);
+
+MODULE_DESCRIPTION("Amlogic HDR Prime SL driver");
+MODULE_LICENSE("GPL");
+
--- /dev/null
+/*
+ * drivers/amlogic/media/enhancement/amprime_sl/amprime_sl.h
+ *
+ * Copyright (C) 2017 Amlogic, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ */
+
+#ifndef __AMPRIME_SL_H__
+#define __AMPRIME_SL_H__
+
+#define DRIVER_VER "20190307"
+
+#define ENABLE 1
+#define DISABLE 0
+
+enum cpuID_e {
+ _CPU_MAJOR_ID_G12,
+ _CPU_MAJOR_ID_TL1,
+ _CPU_MAJOR_ID_UNKNOWN,
+};
+
+struct prime_sl_device_data_s {
+ enum cpuID_e cpu_id;
+};
+
+
+#define PRIMESL_LUTC_ADDR_PORT (0x3980)
+#define PRIMESL_LUTC_DATA_PORT (0x3981)
+#define PRIMESL_LUTP_ADDR_PORT (0x3982)
+#define PRIMESL_LUTP_DATA_PORT (0x3983)
+#define PRIMESL_LUTD_ADDR_PORT (0x3984)
+#define PRIMESL_LUTD_DATA_PORT (0x3985)
+#define PRIMESL_CTRL0 (0x3990)
+union PRIMESL_CTRL0_BITS {
+ unsigned int d32;
+ struct {
+ unsigned int primesl_en:1,
+ gclk_ctrl:2,
+ reg_gclk_ctrl:1,
+ inv_y_ratio:11,
+ reserved3:1,
+ inv_chroma_ratio:11,
+ reserved2:1,
+ clip_en:1,
+ legacy_mode_en:1,
+ reserved1:2;
+ } b;
+};
+#define PRIMESL_CTRL1 (0x3991)
+union PRIMESL_CTRL1_BITS {
+ unsigned int d32;
+ struct {
+ unsigned int footroom:10,
+ reserved2:6,
+ l_headroom:10,
+ reserved1:6;
+ } b;
+};
+#define PRIMESL_CTRL2 (0x3992)
+union PRIMESL_CTRL2_BITS {
+ unsigned int d32;
+ struct {
+ unsigned int c_headroom:10,
+ reserved1:22;
+ } b;
+};
+#define PRIMESL_CTRL3 (0x3993)
+union PRIMESL_CTRL3_BITS {
+ unsigned int d32;
+ struct {
+ unsigned int mua:14,
+ reserved2:2,
+ mub:14,
+ reserved1:2;
+ } b;
+};
+#define PRIMESL_CTRL4 (0x3994)
+union PRIMESL_CTRL4_BITS {
+ unsigned int d32;
+ struct {
+ unsigned int oct_7_0:10,
+ reserved2:6,
+ oct_7_1:10,
+ reserved1:6;
+ } b;
+};
+#define PRIMESL_CTRL5 (0x3995)
+union PRIMESL_CTRL5_BITS {
+ unsigned int d32;
+ struct {
+ unsigned int oct_7_2:10,
+ reserved2:6,
+ oct_7_3:10,
+ reserved1:6;
+ } b;
+};
+#define PRIMESL_CTRL6 (0x3996)
+union PRIMESL_CTRL6_BITS {
+ unsigned int d32;
+ struct {
+ unsigned int oct_7_4:10,
+ reserved2:6,
+ oct_7_5:10,
+ reserved1:6;
+ } b;
+};
+#define PRIMESL_CTRL7 (0x3997)
+union PRIMESL_CTRL7_BITS {
+ unsigned int d32;
+ struct {
+ unsigned int oct_7_6:10,
+ reserved1:22;
+ } b;
+};
+#define PRIMESL_CTRL8 (0x3998)
+union PRIMESL_CTRL8_BITS {
+ unsigned int d32;
+ struct {
+ unsigned int d_lut_threshold_3_0:13,
+ reserved2:3,
+ d_lut_threshold_3_1:13,
+ reserved1:3;
+ } b;
+};
+#define PRIMESL_CTRL9 (0x3999)
+union PRIMESL_CTRL9_BITS {
+ unsigned int d32;
+ struct {
+ unsigned int d_lut_threshold_3_2:13,
+ reserved1:19;
+ } b;
+};
+#define PRIMESL_CTRL10 (0x399a)
+union PRIMESL_CTRL10_BITS {
+ unsigned int d32;
+ struct {
+ unsigned int d_lut_step_4_0:4,
+ d_lut_step_4_1:4,
+ d_lut_step_4_2:4,
+ d_lut_step_4_3:4,
+ reserved1:16;
+ } b;
+};
+#define PRIMESL_CTRL11 (0x399b)
+union PRIMESL_CTRL11_BITS {
+ unsigned int d32;
+ struct {
+ unsigned int rgb2yuv_9_1:13,
+ reserved2:3,
+ rgb2yuv_9_0:13,
+ reserved1:3;
+ } b;
+};
+#define PRIMESL_CTRL12 (0x399c)
+union PRIMESL_CTRL12_BITS {
+ unsigned int d32;
+ struct {
+ unsigned int rgb2yuv_9_3:13,
+ reserved2:3,
+ rgb2yuv_9_2:13,
+ reserved1:3;
+ } b;
+};
+#define PRIMESL_CTRL13 (0x399d)
+union PRIMESL_CTRL13_BITS {
+ unsigned int d32;
+ struct {
+ unsigned int rgb2yuv_9_5:13,
+ reserved2:3,
+ rgb2yuv_9_4:13,
+ reserved1:3;
+ } b;
+};
+#define PRIMESL_CTRL14 (0x399e)
+union PRIMESL_CTRL14_BITS {
+ unsigned int d32;
+ struct {
+ unsigned int rgb2yuv_9_7:13,
+ reserved2:3,
+ rgb2yuv_9_6:13,
+ reserved1:3;
+ } b;
+};
+#define PRIMESL_CTRL15 (0x399f)
+union PRIMESL_CTRL15_BITS {
+ unsigned int d32;
+ struct {
+ unsigned int rgb2yuv_9_8:13,
+ reserved1:19;
+ } b;
+};
+#define PRIME_PRIMESL_EN (0)
+#define PRIME_GCLK_CTRL (1)
+#define PRIME_REG_GCLK_CTRL (2)
+#define PRIME_INV_Y_RATIO (3)
+#define PRIME_INV_CHROMA_RATIO (4)
+#define PRIME_CLIP_EN (5)
+#define PRIME_LEGACY_MODE_EN (6)
+#define PRIME_FOOTROOM (7)
+#define PRIME_L_HEADROOM (8)
+#define PRIME_C_HEADROOM (9)
+#define PRIME_MUA (10)
+#define PRIME_MUB (11)
+#define PRIME_OCT_7_0 (12)
+#define PRIME_OCT_7_1 (13)
+#define PRIME_OCT_7_2 (14)
+#define PRIME_OCT_7_3 (15)
+#define PRIME_OCT_7_4 (16)
+#define PRIME_OCT_7_5 (17)
+#define PRIME_OCT_7_6 (18)
+#define PRIME_D_LUT_THRESHOLD_3_0 (19)
+#define PRIME_D_LUT_THRESHOLD_3_1 (20)
+#define PRIME_D_LUT_THRESHOLD_3_2 (21)
+#define PRIME_D_LUT_STEP_4_0 (22)
+#define PRIME_D_LUT_STEP_4_1 (23)
+#define PRIME_D_LUT_STEP_4_2 (24)
+#define PRIME_D_LUT_STEP_4_3 (25)
+#define PRIME_RGB2YUV_9_0 (26)
+#define PRIME_RGB2YUV_9_1 (27)
+#define PRIME_RGB2YUV_9_2 (28)
+#define PRIME_RGB2YUV_9_3 (29)
+#define PRIME_RGB2YUV_9_4 (30)
+#define PRIME_RGB2YUV_9_5 (31)
+#define PRIME_RGB2YUV_9_6 (32)
+#define PRIME_RGB2YUV_9_7 (33)
+#define PRIME_RGB2YUV_9_8 (34)
+
+
+struct prime_sl_t {
+ unsigned int legacy_mode_en;
+ unsigned int clip_en;
+ unsigned int reg_gclk_ctrl;
+ unsigned int gclk_ctrl;
+ unsigned int primesl_en;
+
+ unsigned int inv_chroma_ratio;
+ unsigned int inv_y_ratio;
+ unsigned int l_headroom;
+ unsigned int footroom;
+ unsigned int c_headroom;
+ unsigned int mub;
+ unsigned int mua;
+ int oct[7];
+ unsigned int d_lut_threshold[3];
+ unsigned int d_lut_step[4];
+ int rgb2yuv[9];
+
+ uint16_t olut_c[65]; /*from */
+ uint16_t olut_p[65];
+ uint16_t olut_d[65];
+
+ unsigned int lut_c[65];
+ unsigned int lut_p[65];
+ unsigned int lut_d[65];
+};
+
+struct sl_hdr_metadata_variables {
+ int tmInputSignalBlackLevelOffset;
+ int tmInputSignalWhiteLevelOffset;
+ int shadowGain;
+ int highlightGain;
+ int midToneWidthAdjFactor;
+ int tmOutputFineTuningNumVal;
+ int tmOutputFineTuningX[10];
+ int tmOutputFineTuningY[10];
+ int saturationGainNumVal;
+ int saturationGainX[6];
+ int saturationGainY[6];
+};
+
+struct sl_hdr_metadata_tables {
+ int luminanceMappingNumVal;
+ int luminanceMappingX[65];
+ int luminanceMappingY[65];
+ int colourCorrectionNumVal;
+ int colourCorrectionX[65];
+ int colourCorrectionY[65];
+};
+
+struct sl_hdr_metadata {
+ int partID;
+ int majorSpecVersionID;
+ int minorSpecVersionID;
+ int payloadMode;
+ int hdrPicColourSpace;
+ int hdrDisplayColourSpace;
+ int hdrDisplayMaxLuminance;
+ int hdrDisplayMinLuminance;
+ int sdrPicColourSpace;
+ int sdrDisplayColourSpace;
+ int sdrDisplayMaxLuminance;
+ int sdrDisplayMinLuminance;
+ int matrixCoefficient[4];
+ int chromaToLumaInjection[2];
+ int kCoefficient[3];
+ union {
+ struct sl_hdr_metadata_variables variables;
+ struct sl_hdr_metadata_tables tables;
+ } u;
+};
+
+struct prime_cfg_t {
+ unsigned int width; /*use?*/
+ unsigned int height; /*use?*/
+ unsigned int bit_depth; /*use?*/
+ int display_OETF; /**/
+ int yuv_range;
+ int display_Brightness;
+};
+
+struct prime_t {
+
+ int en_ic; /*0: ic not support prime sl; 1: ic support prime sl*/
+ int en_top; /*top prime sl switch*/
+ int en_pause;
+ int en_checkdata;
+ int en_count;
+ int en_count_tsk;
+ int en_set;
+ int en_close;
+
+ int ok_count;
+ int ok_set;
+
+ int isr_mode;
+ unsigned int vs_cnt;
+ unsigned int ver_hw;
+ unsigned int ver_fw;
+
+ struct prime_cfg_t *pCfg;
+ struct sl_hdr_metadata *pmta;
+ struct prime_sl_t *pps;
+
+ struct prime_cfg_t Cfg;
+ struct sl_hdr_metadata prime_metadata;
+ struct prime_sl_t prime_sl;
+
+ /*test*/
+ unsigned int dbg_nub;
+ unsigned int dbg_metachange;
+ struct timeval tv[4][2];
+
+};
+
+extern void prime_api_init(void);
+extern void prime_api_exit(void);
+extern void prime_api_isr_process(void);
+extern void prime_api_cmd_process(unsigned char cmd, int para);
+extern unsigned int prime_api_info_show(char *buf, unsigned int size);
+extern int prime_api_store(const char *buf, unsigned int para);
+extern int prime_metadata_parser_process(struct prime_t *prime_sl_setting);
+
+struct hdr_prime_sl_func_s {
+ const char *version_info;
+ void (*prime_api_init)(void);
+ void (*prime_api_exit)(void);
+ void (*prime_api_isr_process)(void);
+ void (*prime_api_cmd_process)(unsigned char cmd, int para);
+ unsigned int (*prime_api_info_show)(char *buf, unsigned int size);
+ int (*prime_api_store)(const char *buf, unsigned int para);
+ int (*prime_metadata_parser_process)(struct prime_t *prime_sl_setting);
+};
+
+extern int register_prime_functions(const struct hdr_prime_sl_func_s *func);
+extern int unregister_prime_functions(void);
+
+#ifndef CONFIG_AMLOGIC_MEDIA_VSYNC_RDMA
+#define _VSYNC_WR_MPEG_REG(adr, val) WRITE_VPP_REG(adr, val)
+#define _VSYNC_RD_MPEG_REG(adr) READ_VPP_REG(adr)
+#define _VSYNC_WR_MPEG_REG_BITS(adr, val, start, len) \
+ WRITE_VPP_REG_BITS(adr, val, start, len)
+#else
+extern int _VSYNC_WR_MPEG_REG_BITS(u32 adr, u32 val, u32 start, u32 len);
+extern u32 _VSYNC_RD_MPEG_REG(u32 adr);
+extern int _VSYNC_WR_MPEG_REG(u32 adr, u32 val);
+#endif
+extern void prime_sl_set_reg(const struct prime_sl_t *pS);
+extern void prime_sl_close(void);
+
+
+#endif /*__REG_G12A_PRIME_H__*/
--- /dev/null
+/*
+ * drivers/amlogic/media/enhancement/amprime_sl/amprime_sl_hw.c
+ *
+ * Copyright (C) 2017 Amlogic, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ */
+
+#include <linux/types.h>
+
+
+#include <linux/jiffies.h>
+#include<linux/ktime.h> /*gettimeofday*/
+#include<linux/timekeeping.h> /*gettimeofday*/
+
+#include <linux/amlogic/media/amvecm/amvecm.h> /*WRITE_VPP_REG*/
+#include "amprime_sl.h"
+
+/*======================================*/
+/*#define USE_TASKLET 1*/
+
+static inline void wbits_PRIMESL_CTRL0(
+ unsigned int primesl_en, unsigned int gclk_ctrl,
+ unsigned int reg_gclk_ctrl, unsigned int inv_y_ratio,
+ unsigned int inv_chroma_ratio, unsigned int clip_en,
+ unsigned int legacy_mode_en)
+{
+ union PRIMESL_CTRL0_BITS v;
+
+ v.b.primesl_en = primesl_en;
+ v.b.gclk_ctrl = gclk_ctrl;
+ v.b.reg_gclk_ctrl = reg_gclk_ctrl;
+ v.b.inv_y_ratio = inv_y_ratio;
+ v.b.inv_chroma_ratio = inv_chroma_ratio;
+ v.b.clip_en = clip_en;
+ v.b.legacy_mode_en = legacy_mode_en;
+ _VSYNC_WR_MPEG_REG(PRIMESL_CTRL0, v.d32);
+}
+static inline void wbits_PRIMESL_CTRL1(unsigned int footroom,
+ unsigned int l_headroom)
+{
+ union PRIMESL_CTRL1_BITS v;
+
+ v.b.footroom = footroom;
+ v.b.l_headroom = l_headroom;
+ _VSYNC_WR_MPEG_REG(PRIMESL_CTRL1, v.d32);
+}
+static inline void wbits_PRIMESL_CTRL2(unsigned int c_headroom)
+{
+ union PRIMESL_CTRL2_BITS v;
+
+ v.b.c_headroom = c_headroom;
+ _VSYNC_WR_MPEG_REG(PRIMESL_CTRL2, v.d32);
+}
+static inline void wbits_PRIMESL_CTRL3(unsigned int mua,
+ unsigned int mub)
+{
+ union PRIMESL_CTRL3_BITS v;
+
+ v.b.mua = mua;
+ v.b.mub = mub;
+ _VSYNC_WR_MPEG_REG(PRIMESL_CTRL3, v.d32);
+}
+static inline void wbits_PRIMESL_CTRL4(unsigned int oct_7_0,
+ unsigned int oct_7_1)
+{
+ union PRIMESL_CTRL4_BITS v;
+
+ v.b.oct_7_0 = oct_7_0;
+ v.b.oct_7_1 = oct_7_1;
+ _VSYNC_WR_MPEG_REG(PRIMESL_CTRL4, v.d32);
+}
+static inline void wbits_PRIMESL_CTRL5(unsigned int oct_7_2,
+ unsigned int oct_7_3)
+{
+ union PRIMESL_CTRL5_BITS v;
+
+ v.b.oct_7_2 = oct_7_2;
+ v.b.oct_7_3 = oct_7_3;
+ _VSYNC_WR_MPEG_REG(PRIMESL_CTRL5, v.d32);
+}
+static inline void wbits_PRIMESL_CTRL6(unsigned int oct_7_4,
+ unsigned int oct_7_5)
+{
+ union PRIMESL_CTRL6_BITS v;
+
+ v.b.oct_7_4 = oct_7_4;
+ v.b.oct_7_5 = oct_7_5;
+ _VSYNC_WR_MPEG_REG(PRIMESL_CTRL6, v.d32);
+}
+static inline void wbits_PRIMESL_CTRL7(unsigned int oct_7_6)
+{
+ union PRIMESL_CTRL7_BITS v;
+
+ v.b.oct_7_6 = oct_7_6;
+ _VSYNC_WR_MPEG_REG(PRIMESL_CTRL7, v.d32);
+}
+static inline void wbits_PRIMESL_CTRL8(unsigned int d_lut_threshold_3_0,
+ unsigned int d_lut_threshold_3_1)
+{
+ union PRIMESL_CTRL8_BITS v;
+
+ v.b.d_lut_threshold_3_0 = d_lut_threshold_3_0;
+ v.b.d_lut_threshold_3_1 = d_lut_threshold_3_1;
+ _VSYNC_WR_MPEG_REG(PRIMESL_CTRL8, v.d32);
+}
+static inline void wbits_PRIMESL_CTRL9(unsigned int d_lut_threshold_3_2)
+{
+ union PRIMESL_CTRL9_BITS v;
+
+ v.b.d_lut_threshold_3_2 = d_lut_threshold_3_2;
+ _VSYNC_WR_MPEG_REG(PRIMESL_CTRL9, v.d32);
+}
+static inline void wbits_PRIMESL_CTRL10(unsigned int d_lut_step_4_0,
+ unsigned int d_lut_step_4_1,
+ unsigned int d_lut_step_4_2,
+ unsigned int d_lut_step_4_3)
+{
+ union PRIMESL_CTRL10_BITS v;
+
+ v.b.d_lut_step_4_0 = d_lut_step_4_0;
+ v.b.d_lut_step_4_1 = d_lut_step_4_1;
+ v.b.d_lut_step_4_2 = d_lut_step_4_2;
+ v.b.d_lut_step_4_3 = d_lut_step_4_3;
+ _VSYNC_WR_MPEG_REG(PRIMESL_CTRL10, v.d32);
+}
+static inline void wbits_PRIMESL_CTRL11(unsigned int rgb2yuv_9_1,
+ unsigned int rgb2yuv_9_0)
+{
+ union PRIMESL_CTRL11_BITS v;
+
+ v.b.rgb2yuv_9_1 = rgb2yuv_9_1;
+ v.b.rgb2yuv_9_0 = rgb2yuv_9_0;
+ _VSYNC_WR_MPEG_REG(PRIMESL_CTRL11, v.d32);
+}
+static inline void wbits_PRIMESL_CTRL12(unsigned int rgb2yuv_9_3,
+ unsigned int rgb2yuv_9_2)
+{
+ union PRIMESL_CTRL12_BITS v;
+
+ v.b.rgb2yuv_9_3 = rgb2yuv_9_3;
+ v.b.rgb2yuv_9_2 = rgb2yuv_9_2;
+ _VSYNC_WR_MPEG_REG(PRIMESL_CTRL12, v.d32);
+}
+static inline void wbits_PRIMESL_CTRL13(unsigned int rgb2yuv_9_5,
+ unsigned int rgb2yuv_9_4)
+{
+ union PRIMESL_CTRL13_BITS v;
+
+ v.b.rgb2yuv_9_5 = rgb2yuv_9_5;
+ v.b.rgb2yuv_9_4 = rgb2yuv_9_4;
+ _VSYNC_WR_MPEG_REG(PRIMESL_CTRL13, v.d32);
+}
+static inline void wbits_PRIMESL_CTRL14(unsigned int rgb2yuv_9_7,
+ unsigned int rgb2yuv_9_6)
+{
+ union PRIMESL_CTRL14_BITS v;
+
+ v.b.rgb2yuv_9_7 = rgb2yuv_9_7;
+ v.b.rgb2yuv_9_6 = rgb2yuv_9_6;
+ _VSYNC_WR_MPEG_REG(PRIMESL_CTRL14, v.d32);
+}
+static inline void wbits_PRIMESL_CTRL15(unsigned int rgb2yuv_9_8)
+{
+ union PRIMESL_CTRL15_BITS v;
+
+ v.b.rgb2yuv_9_8 = rgb2yuv_9_8;
+ _VSYNC_WR_MPEG_REG(PRIMESL_CTRL15, v.d32);
+}
+
+#define NOT_USR_WR_T 1
+
+void slctr_set_rgb2yuv(const int *pTab)/*9byte*/
+{
+#ifdef NOT_USR_WR_T
+ wbits_PRIMESL_CTRL11(pTab[1], pTab[0]);
+ wbits_PRIMESL_CTRL12(pTab[3], pTab[2]);
+ wbits_PRIMESL_CTRL13(pTab[5], pTab[4]);
+ wbits_PRIMESL_CTRL14(pTab[7], pTab[6]);
+ wbits_PRIMESL_CTRL15(pTab[8]);
+
+#else
+ int i;
+
+ for (i = 0; i < 9; i++)
+ WR_T(PRIME_RGB2YUV_9_0+i, (unsigned int)pTab[i]);
+#endif
+}
+
+void slctr_set_lutstep(const unsigned int *pTab)/*4byte*/
+{
+
+#ifdef NOT_USR_WR_T
+ wbits_PRIMESL_CTRL10(pTab[0], pTab[1], pTab[2], pTab[3]);
+
+#else
+ int i;
+
+ for (i = 0; i < 4; i++)
+ WR_T(PRIME_D_LUT_STEP_4_0+i, pTab[i]);
+
+#endif
+}
+void slctr_set_lutthrd(const unsigned int *pTab)/*3byte*/
+{
+
+#ifdef NOT_USR_WR_T
+ wbits_PRIMESL_CTRL8(pTab[0], pTab[1]);
+ wbits_PRIMESL_CTRL9(pTab[2]);
+#else
+ int i;
+
+ for (i = 0; i < 3; i++)
+ WR_T(PRIME_D_LUT_THRESHOLD_3_0+i, pTab[i]);
+
+#endif
+}
+void slctr_set_oct(const int *pTab)/*7byte*/
+{
+
+#ifdef NOT_USR_WR_T
+ wbits_PRIMESL_CTRL4(pTab[0], pTab[1]);
+ wbits_PRIMESL_CTRL5(pTab[2], pTab[3]);
+ wbits_PRIMESL_CTRL6(pTab[4], pTab[5]);
+ wbits_PRIMESL_CTRL7(pTab[6]);
+#else
+ int i;
+
+ for (i = 0; i < 7; i++)
+ WR_T(PRIME_OCT_7_0+i, (unsigned int)pTab[i]);
+#endif
+}
+void slctr_set_lut_c(const int *pTab)/*7byte*/
+{
+ int i;
+
+ _VSYNC_WR_MPEG_REG(PRIMESL_LUTC_ADDR_PORT, 0);
+ for (i = 0; i < 65; i++)
+ _VSYNC_WR_MPEG_REG(PRIMESL_LUTC_DATA_PORT, pTab[i]);
+}
+
+void slctr_set_lut_p(const int *pTab)/*7byte*/
+{
+ int i;
+
+ _VSYNC_WR_MPEG_REG(PRIMESL_LUTP_ADDR_PORT, 0);
+ for (i = 0; i < 65; i++)
+ _VSYNC_WR_MPEG_REG(PRIMESL_LUTP_DATA_PORT, pTab[i]);
+}
+
+void slctr_set_lut_d(const int *pTab)/*7byte*/
+{
+ int i;
+
+ _VSYNC_WR_MPEG_REG(PRIMESL_LUTD_ADDR_PORT, 0);
+ for (i = 0; i < 65; i++)
+ _VSYNC_WR_MPEG_REG(PRIMESL_LUTD_DATA_PORT, pTab[i]);
+}
+
+void prime_sl_set_reg(const struct prime_sl_t *pS)
+{
+ wbits_PRIMESL_CTRL1(pS->footroom, pS->l_headroom);
+ wbits_PRIMESL_CTRL2(pS->c_headroom);
+ wbits_PRIMESL_CTRL3(pS->mua, pS->mub);
+ slctr_set_oct(&pS->oct[0]);
+ slctr_set_lutthrd(&pS->d_lut_threshold[0]);
+ slctr_set_lutstep(&pS->d_lut_step[0]);
+ slctr_set_rgb2yuv(&pS->rgb2yuv[0]);
+ slctr_set_lut_c(&pS->lut_c[0]);
+ slctr_set_lut_p(&pS->lut_p[0]);
+ slctr_set_lut_d(&pS->lut_d[0]);
+
+ wbits_PRIMESL_CTRL0(1, 0, 0, pS->inv_y_ratio,
+ pS->inv_chroma_ratio, 0, 0);
+}
+void prime_sl_close(void)
+{
+ wbits_PRIMESL_CTRL0(0, 0, 0, 0, 0, 0, 0);
+}
+
--- /dev/null
+/*
+ * include/linux/amlogic/media/amprime_sl/prime_sl.h
+ *
+ * Copyright (C) 2017 Amlogic, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ */
+
+#ifndef _PRIMSE_SL_H_
+#define _PRIMSE_SL_H_
+
+#include <linux/types.h>
+
+extern void prime_sl_process(struct vframe_s *vf);
+extern bool is_dolby_vision_enable(void);
+
+#endif