| /* Copyright (c) 2017, The Linux Foundation. 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 version 2 and |
| * only version 2 as published by the Free Software Foundation. |
| * |
| * 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/debugfs.h> |
| #include <linux/dma-mapping.h> |
| #include <linux/init.h> |
| #include <linux/ioctl.h> |
| #include <linux/list.h> |
| #include <linux/module.h> |
| #include <linux/of_platform.h> |
| #include <linux/platform_device.h> |
| #include <linux/slab.h> |
| #include <linux/types.h> |
| #include <linux/version.h> |
| #include <linux/io.h> |
| #include "msm_vidc_internal.h" |
| |
| |
| #define CODEC_ENTRY(n, p, vsp, vpp, lp) \ |
| { \ |
| .fourcc = n, \ |
| .session_type = p, \ |
| .vsp_cycles = vsp, \ |
| .vpp_cycles = vpp, \ |
| .low_power_cycles = lp \ |
| } |
| |
| static struct msm_vidc_codec_data default_codec_data[] = { |
| CODEC_ENTRY(V4L2_PIX_FMT_H264, MSM_VIDC_ENCODER, 125, 675, 320), |
| CODEC_ENTRY(V4L2_PIX_FMT_H264, MSM_VIDC_DECODER, 125, 675, 320), |
| }; |
| |
| static struct msm_vidc_codec_data sdm845_codec_data[] = { |
| CODEC_ENTRY(V4L2_PIX_FMT_H264, MSM_VIDC_ENCODER, 125, 675, 320), |
| CODEC_ENTRY(V4L2_PIX_FMT_HEVC, MSM_VIDC_ENCODER, 125, 675, 320), |
| CODEC_ENTRY(V4L2_PIX_FMT_VP8, MSM_VIDC_ENCODER, 125, 675, 320), |
| CODEC_ENTRY(V4L2_PIX_FMT_MPEG2, MSM_VIDC_DECODER, 50, 200, 200), |
| CODEC_ENTRY(V4L2_PIX_FMT_H264, MSM_VIDC_DECODER, 50, 200, 200), |
| CODEC_ENTRY(V4L2_PIX_FMT_HEVC, MSM_VIDC_DECODER, 50, 200, 200), |
| CODEC_ENTRY(V4L2_PIX_FMT_VP8, MSM_VIDC_DECODER, 50, 200, 200), |
| CODEC_ENTRY(V4L2_PIX_FMT_VP9, MSM_VIDC_DECODER, 50, 200, 200), |
| }; |
| |
| static struct msm_vidc_common_data default_common_data[] = { |
| { |
| .key = "qcom,never-unload-fw", |
| .value = 1, |
| }, |
| }; |
| |
| static struct msm_vidc_common_data sdm845_common_data[] = { |
| { |
| .key = "qcom,never-unload-fw", |
| .value = 1, |
| }, |
| { |
| .key = "qcom,sw-power-collapse", |
| .value = 1, |
| }, |
| { |
| .key = "qcom,max-secure-instances", |
| .value = 5, |
| }, |
| { |
| .key = "qcom,max-hw-load", |
| .value = 2563200, |
| }, |
| { |
| .key = "qcom,max-hq-mbs-per-frame", |
| .value = 8160, |
| }, |
| { |
| .key = "qcom,max-hq-frames-per-sec", |
| .value = 60, |
| }, |
| { |
| .key = "qcom,max-b-frame-size", |
| .value = 8160, |
| }, |
| { |
| .key = "qcom,max-b-frames-per-sec", |
| .value = 60, |
| }, |
| { |
| .key = "qcom,power-collapse-delay", |
| .value = 500, |
| }, |
| { |
| .key = "qcom,hw-resp-timeout", |
| .value = 250, |
| }, |
| }; |
| |
| |
| static struct msm_vidc_platform_data default_data = { |
| .codec_data = default_codec_data, |
| .codec_data_length = ARRAY_SIZE(default_codec_data), |
| .common_data = default_common_data, |
| .common_data_length = ARRAY_SIZE(default_common_data), |
| }; |
| |
| static struct msm_vidc_platform_data sdm845_data = { |
| .codec_data = sdm845_codec_data, |
| .codec_data_length = ARRAY_SIZE(sdm845_codec_data), |
| .common_data = sdm845_common_data, |
| .common_data_length = ARRAY_SIZE(sdm845_common_data), |
| }; |
| |
| static const struct of_device_id msm_vidc_dt_match[] = { |
| { |
| .compatible = "qcom,sdm845-vidc", |
| .data = &sdm845_data, |
| }, |
| {}, |
| }; |
| |
| MODULE_DEVICE_TABLE(of, msm_vidc_dt_match); |
| |
| void *vidc_get_drv_data(struct device *dev) |
| { |
| struct msm_vidc_platform_data *driver_data = NULL; |
| const struct of_device_id *match; |
| |
| if (!IS_ENABLED(CONFIG_OF) || !dev->of_node) { |
| driver_data = &default_data; |
| goto exit; |
| } |
| |
| match = of_match_node(msm_vidc_dt_match, dev->of_node); |
| |
| if (match) |
| driver_data = (struct msm_vidc_platform_data *)match->data; |
| |
| exit: |
| return driver_data; |
| } |