media: venus: Add codec data table
authorAniket Masule <amasule@codeaurora.org>
Tue, 24 Sep 2019 05:47:48 +0000 (02:47 -0300)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Fri, 4 Oct 2019 11:52:43 +0000 (08:52 -0300)
Add vpp cycles for different types of codec.
It indicates the cycles required by video hardware
to process each macroblock. Add vsp cycles, cycles
required by stream processor. Initialize the codec
data with core resources.

Signed-off-by: Aniket Masule <amasule@codeaurora.org>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/platform/qcom/venus/core.c
drivers/media/platform/qcom/venus/core.h
drivers/media/platform/qcom/venus/helpers.c
drivers/media/platform/qcom/venus/helpers.h
drivers/media/platform/qcom/venus/vdec.c
drivers/media/platform/qcom/venus/venc.c

index 8d662c8f3769b74501032b3ceec095edda790bb6..07312a2fab2478dee747fe3a17f3742140ddbc33 100644 (file)
@@ -481,6 +481,17 @@ static const struct freq_tbl sdm845_freq_table[] = {
        {  244800, 100000000 }, /* 1920x1080@30 */
 };
 
+static struct codec_freq_data sdm845_codec_freq_data[] =  {
+       { V4L2_PIX_FMT_H264, VIDC_SESSION_TYPE_ENC, 675, 10 },
+       { V4L2_PIX_FMT_HEVC, VIDC_SESSION_TYPE_ENC, 675, 10 },
+       { V4L2_PIX_FMT_VP8, VIDC_SESSION_TYPE_ENC, 675, 10 },
+       { V4L2_PIX_FMT_MPEG2, VIDC_SESSION_TYPE_DEC, 200, 10 },
+       { V4L2_PIX_FMT_H264, VIDC_SESSION_TYPE_DEC, 200, 10 },
+       { V4L2_PIX_FMT_HEVC, VIDC_SESSION_TYPE_DEC, 200, 10 },
+       { V4L2_PIX_FMT_VP8, VIDC_SESSION_TYPE_DEC, 200, 10 },
+       { V4L2_PIX_FMT_VP9, VIDC_SESSION_TYPE_DEC, 200, 10 },
+};
+
 static const struct bw_tbl sdm845_bw_table_enc[] = {
        { 1944000, 1612000, 0, 2416000, 0 },    /* 3840x2160@60 */
        {  972000,  951000, 0, 1434000, 0 },    /* 3840x2160@30 */
@@ -502,6 +513,8 @@ static const struct venus_resources sdm845_res = {
        .bw_tbl_enc_size = ARRAY_SIZE(sdm845_bw_table_enc),
        .bw_tbl_dec = sdm845_bw_table_dec,
        .bw_tbl_dec_size = ARRAY_SIZE(sdm845_bw_table_dec),
+       .codec_freq_data = sdm845_codec_freq_data,
+       .codec_freq_data_size = ARRAY_SIZE(sdm845_codec_freq_data),
        .clks = {"core", "iface", "bus" },
        .clks_num = 3,
        .max_load = 3110400,    /* 4096x2160@90 */
index 661eaa7b81ec0590fd557b5efb282c514be6894e..11585fb3cae35850fcb115af723385560885d92f 100644 (file)
@@ -26,6 +26,13 @@ struct reg_val {
        u32 value;
 };
 
+struct codec_freq_data {
+       u32 pixfmt;
+       u32 session_type;
+       unsigned long vpp_freq;
+       unsigned long vsp_freq;
+};
+
 struct bw_tbl {
        u32 mbs_per_sec;
        u32 avg;
@@ -44,6 +51,8 @@ struct venus_resources {
        unsigned int bw_tbl_dec_size;
        const struct reg_val *reg_tbl;
        unsigned int reg_tbl_size;
+       const struct codec_freq_data *codec_freq_data;
+       unsigned int codec_freq_data_size;
        const char * const clks[VIDC_CLKS_NUM_MAX];
        unsigned int clks_num;
        enum hfi_version hfi_version;
@@ -222,6 +231,12 @@ struct venus_buffer {
        struct list_head ref_list;
 };
 
+struct clock_data {
+       u32 core_id;
+       unsigned long freq;
+       const struct codec_freq_data *codec_freq_data;
+};
+
 #define to_venus_buffer(ptr)   container_of(ptr, struct venus_buffer, vb)
 
 enum venus_dec_state {
@@ -302,6 +317,7 @@ struct venus_inst {
        struct list_head list;
        struct mutex lock;
        struct venus_core *core;
+       struct clock_data clk_data;
        struct list_head dpbbufs;
        struct list_head internalbufs;
        struct list_head registeredbufs;
index f18458921f5dc21b8f53ea6554b8f40fcdeaa282..94fd071217c37862a37e35119f0413a7d9d90877 100644 (file)
@@ -883,6 +883,36 @@ int venus_helper_set_core_usage(struct venus_inst *inst, u32 usage)
 }
 EXPORT_SYMBOL_GPL(venus_helper_set_core_usage);
 
+int venus_helper_init_codec_freq_data(struct venus_inst *inst)
+{
+       const struct codec_freq_data *data;
+       unsigned int i, data_size;
+       u32 pixfmt;
+       int ret = 0;
+
+       if (!IS_V4(inst->core))
+               return 0;
+
+       data = inst->core->res->codec_freq_data;
+       data_size = inst->core->res->codec_freq_data_size;
+       pixfmt = inst->session_type == VIDC_SESSION_TYPE_DEC ?
+                       inst->fmt_out->pixfmt : inst->fmt_cap->pixfmt;
+
+       for (i = 0; i < data_size; i++) {
+               if (data[i].pixfmt == pixfmt &&
+                   data[i].session_type == inst->session_type) {
+                       inst->clk_data.codec_freq_data = &data[i];
+                       break;
+               }
+       }
+
+       if (!inst->clk_data.codec_freq_data)
+               ret = -EINVAL;
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(venus_helper_init_codec_freq_data);
+
 int venus_helper_set_num_bufs(struct venus_inst *inst, unsigned int input_bufs,
                              unsigned int output_bufs,
                              unsigned int output2_bufs)
index 01f411b12f813fc8d4ecacb6a75d1be92aabe081..08abe0293c91654f1c898be324958cc72698abd5 100644 (file)
@@ -33,6 +33,7 @@ int venus_helper_set_output_resolution(struct venus_inst *inst,
                                       unsigned int width, unsigned int height,
                                       u32 buftype);
 int venus_helper_set_work_mode(struct venus_inst *inst, u32 mode);
+int venus_helper_init_codec_freq_data(struct venus_inst *inst);
 int venus_helper_set_core_usage(struct venus_inst *inst, u32 usage);
 int venus_helper_set_num_bufs(struct venus_inst *inst, unsigned int input_bufs,
                              unsigned int output_bufs,
index 7f4660555ddbdfb724d5bf8fe336e9fa8eded2fd..18a861d7f31f55037217a580bdba4b4d050ff9b8 100644 (file)
@@ -685,6 +685,10 @@ static int vdec_session_init(struct venus_inst *inst)
        if (ret)
                goto deinit;
 
+       ret = venus_helper_init_codec_freq_data(inst);
+       if (ret)
+               goto deinit;
+
        return 0;
 deinit:
        hfi_session_deinit(inst);
index 1b7fb2d5887c6a07fcb425c40ec7356dd011e0f5..501fb8ca55fb115e2c89975ea29a7f7f25a97be9 100644 (file)
@@ -842,6 +842,10 @@ static int venc_init_session(struct venus_inst *inst)
        if (ret)
                goto deinit;
 
+       ret = venus_helper_init_codec_freq_data(inst);
+       if (ret)
+               goto deinit;
+
        ret = venc_set_properties(inst);
        if (ret)
                goto deinit;