Merge "video: driver: add power changes" into video-kernel-waipio.lnx.1.0
Esse commit está contido em:

commit de
Gerrit - the friendly Code Review server

commit
ff84f38821
@@ -8,6 +8,15 @@
|
||||
|
||||
#include "msm_vidc_inst.h"
|
||||
|
||||
#define MIN_DEC_INPUT_BUFFERS 4
|
||||
#define MIN_DEC_OUTPUT_BUFFERS 4
|
||||
|
||||
#define MIN_ENC_INPUT_BUFFERS 4
|
||||
#define MIN_ENC_OUTPUT_BUFFERS 4
|
||||
|
||||
#define DCVS_ENC_EXTRA_INPUT_BUFFERS 4
|
||||
#define DCVS_DEC_EXTRA_OUTPUT_BUFFERS 4
|
||||
|
||||
u32 msm_vidc_input_min_count(struct msm_vidc_inst *inst);
|
||||
u32 msm_vidc_output_min_count(struct msm_vidc_inst *inst);
|
||||
u32 msm_vidc_input_extra_count(struct msm_vidc_inst *inst);
|
||||
|
@@ -22,6 +22,7 @@
|
||||
extern int msm_vidc_debug;
|
||||
extern bool msm_vidc_lossless_encode;
|
||||
extern bool msm_vidc_syscache_disable;
|
||||
extern int msm_vidc_clock_voting;
|
||||
|
||||
/* To enable messages OR these values and
|
||||
* echo the result to debugfs file.
|
||||
|
@@ -12,6 +12,8 @@
|
||||
#include "msm_vidc_core.h"
|
||||
#include "msm_vidc_inst.h"
|
||||
|
||||
#define MSM_VIDC_SESSION_INACTIVE_THRESHOLD_MS 1000
|
||||
|
||||
static inline is_decode_session(struct msm_vidc_inst *inst)
|
||||
{
|
||||
return inst->domain == MSM_VIDC_DECODER;
|
||||
@@ -59,16 +61,57 @@ static inline is_internal_buffer(enum msm_vidc_buffer_type buffer_type)
|
||||
buffer_type == MSM_VIDC_BUF_VPSS;
|
||||
}
|
||||
|
||||
static inline bool is_linear_colorformat(enum msm_vidc_colorformat_type colorformat)
|
||||
{
|
||||
return colorformat == MSM_VIDC_FMT_NV12 ||
|
||||
colorformat == MSM_VIDC_FMT_NV21 ||
|
||||
colorformat == MSM_VIDC_FMT_NV12_P010;
|
||||
}
|
||||
|
||||
static inline bool is_10bit_colorformat(enum msm_vidc_colorformat_type colorformat)
|
||||
{
|
||||
return colorformat == MSM_VIDC_FMT_NV12_P010 ||
|
||||
colorformat == MSM_VIDC_FMT_NV12_TP10_UBWC;
|
||||
}
|
||||
|
||||
static inline bool is_secondary_output_mode(struct msm_vidc_inst *inst)
|
||||
{
|
||||
return false; // TODO: inst->stream_output_mode == HAL_VIDEO_DECODER_SECONDARY;
|
||||
}
|
||||
|
||||
static inline bool is_turbo_session(struct msm_vidc_inst *inst)
|
||||
{
|
||||
return !!(inst->flags & VIDC_TURBO);
|
||||
}
|
||||
|
||||
static inline bool is_thumbnail_session(struct msm_vidc_inst *inst)
|
||||
{
|
||||
return !!(inst->flags & VIDC_THUMBNAIL);
|
||||
}
|
||||
|
||||
static inline bool is_low_power_session(struct msm_vidc_inst *inst)
|
||||
{
|
||||
return !!(inst->flags & VIDC_LOW_POWER);
|
||||
}
|
||||
|
||||
static inline bool is_realtime_session(struct msm_vidc_inst *inst)
|
||||
{
|
||||
return false; // TODO: fix it
|
||||
}
|
||||
|
||||
static inline bool is_active_session(u64 prev, u64 curr)
|
||||
{
|
||||
u64 ts_delta;
|
||||
|
||||
if (!prev || !curr)
|
||||
return true;
|
||||
|
||||
ts_delta = (prev < curr) ? curr - prev : prev - curr;
|
||||
|
||||
return ((ts_delta / NSEC_PER_MSEC) <=
|
||||
MSM_VIDC_SESSION_INACTIVE_THRESHOLD_MS);
|
||||
}
|
||||
|
||||
void print_vidc_buffer(u32 tag, const char *str, struct msm_vidc_inst *inst,
|
||||
struct msm_vidc_buffer *vbuf);
|
||||
void print_vb2_buffer(const char *str, struct msm_vidc_inst *inst,
|
||||
@@ -99,6 +142,8 @@ int msm_vidc_remove_session(struct msm_vidc_inst *inst);
|
||||
int msm_vidc_add_session(struct msm_vidc_inst *inst);
|
||||
int msm_vidc_session_open(struct msm_vidc_inst *inst);
|
||||
int msm_vidc_session_set_codec(struct msm_vidc_inst *inst);
|
||||
int msm_vidc_session_start(struct msm_vidc_inst* inst,
|
||||
enum msm_vidc_port_type port);
|
||||
int msm_vidc_session_stop(struct msm_vidc_inst *inst,
|
||||
enum msm_vidc_port_type port);
|
||||
int msm_vidc_session_close(struct msm_vidc_inst *inst);
|
||||
@@ -140,6 +185,9 @@ struct msm_vidc_buffer *get_meta_buffer(struct msm_vidc_inst *inst,
|
||||
struct msm_vidc_inst *get_inst(struct msm_vidc_core *core,
|
||||
u32 session_id);
|
||||
void put_inst(struct msm_vidc_inst *inst);
|
||||
int msm_vidc_get_mbs_per_frame(struct msm_vidc_inst* inst);
|
||||
int msm_vidc_get_fps(struct msm_vidc_inst* inst);
|
||||
int msm_vidc_num_queued_bufs(struct msm_vidc_inst* inst, u32 type);
|
||||
void core_lock(struct msm_vidc_core *core, const char *function);
|
||||
void core_unlock(struct msm_vidc_core *core, const char *function);
|
||||
void inst_lock(struct msm_vidc_inst *inst, const char *function);
|
||||
|
@@ -15,8 +15,9 @@ struct msm_vidc_inst;
|
||||
((c)->session_ops->op(__VA_ARGS__)) : 0)
|
||||
|
||||
struct msm_vidc_session_ops {
|
||||
u64 (*calc_freq)(struct msm_vidc_inst *inst);
|
||||
u64 (*calc_bw)(struct msm_vidc_inst *inst);
|
||||
u64 (*calc_freq)(struct msm_vidc_inst *inst, u32 data_size);
|
||||
int (*calc_bw)(struct msm_vidc_inst *inst,
|
||||
struct vidc_bus_vote_data* vote_data);
|
||||
int (*decide_work_route)(struct msm_vidc_inst *inst);
|
||||
int (*decide_work_mode)(struct msm_vidc_inst *inst);
|
||||
int (*decide_core_and_power_mode)(struct msm_vidc_inst *inst);
|
||||
@@ -105,6 +106,8 @@ struct msm_vidc_inst {
|
||||
enum msm_vidc_pipe_type pipe;
|
||||
enum msm_vidc_quality_mode quality_mode;
|
||||
struct msm_vidc_power power;
|
||||
enum msm_vidc_modes flags;
|
||||
struct vidc_bus_vote_data bus_data;
|
||||
struct msm_vidc_buffers_info buffers;
|
||||
struct msm_vidc_mappings_info mappings;
|
||||
struct msm_vidc_allocations_info allocations;
|
||||
@@ -126,6 +129,8 @@ struct msm_vidc_inst {
|
||||
struct msm_vidc_debug debug;
|
||||
struct msm_vidc_inst_capability *capabilities;
|
||||
struct completion completions[MAX_SIGNAL];
|
||||
bool active;
|
||||
u64 last_qbuf_time_ns;
|
||||
};
|
||||
|
||||
#endif // _MSM_VIDC_INST_H_
|
||||
|
@@ -80,6 +80,7 @@
|
||||
#define BUFFER_ALIGNMENT_SIZE(x) x
|
||||
#define NUM_MBS_720P (((1280 + 15) >> 4) * ((720 + 15) >> 4))
|
||||
#define NUM_MBS_4k (((4096 + 15) >> 4) * ((2304 + 15) >> 4))
|
||||
#define MB_SIZE_IN_PIXEL (16 * 16)
|
||||
|
||||
#define DB_H264_DISABLE_SLICE_BOUNDARY \
|
||||
V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED_AT_SLICE_BOUNDARY
|
||||
@@ -554,6 +555,7 @@ struct msm_vidc_crop {
|
||||
struct msm_vidc_properties {
|
||||
u32 frame_rate;
|
||||
u32 operating_rate;
|
||||
u32 bitrate;
|
||||
};
|
||||
|
||||
struct msm_vidc_subscription_params {
|
||||
@@ -581,7 +583,48 @@ struct msm_vidc_decode_batch {
|
||||
struct delayed_work work;
|
||||
};
|
||||
|
||||
enum msm_vidc_modes {
|
||||
VIDC_SECURE = BIT(0),
|
||||
VIDC_TURBO = BIT(1),
|
||||
VIDC_THUMBNAIL = BIT(2),
|
||||
VIDC_LOW_POWER = BIT(3),
|
||||
};
|
||||
|
||||
enum load_calc_quirks {
|
||||
LOAD_POWER = 0,
|
||||
LOAD_ADMISSION_CONTROL = 1,
|
||||
};
|
||||
|
||||
enum msm_vidc_power_mode {
|
||||
VIDC_POWER_NORMAL = 0,
|
||||
VIDC_POWER_LOW,
|
||||
VIDC_POWER_TURBO,
|
||||
};
|
||||
|
||||
struct vidc_bus_vote_data {
|
||||
enum msm_vidc_domain_type domain;
|
||||
enum msm_vidc_codec_type codec;
|
||||
enum msm_vidc_power_mode power_mode;
|
||||
u32 color_formats[2];
|
||||
int num_formats; /* 1 = DPB-OPB unified; 2 = split */
|
||||
int input_height, input_width, bitrate;
|
||||
int output_height, output_width;
|
||||
int rotation;
|
||||
int compression_ratio;
|
||||
int complexity_factor;
|
||||
int input_cr;
|
||||
u32 lcu_size;
|
||||
u32 fps;
|
||||
u32 work_mode;
|
||||
bool use_sys_cache;
|
||||
bool b_frames_enabled;
|
||||
u64 calc_bw_ddr;
|
||||
u64 calc_bw_llcc;
|
||||
u32 num_vpp_pipes;
|
||||
};
|
||||
|
||||
struct msm_vidc_power {
|
||||
enum msm_vidc_power_mode power_mode;
|
||||
u32 buffer_counter;
|
||||
u32 min_threshold;
|
||||
u32 nom_threshold;
|
||||
|
@@ -6,8 +6,249 @@
|
||||
#ifndef _MSM_VIDC_POWER_H_
|
||||
#define _MSM_VIDC_POWER_H_
|
||||
|
||||
#include "fixedpoint.h"
|
||||
#include "msm_vidc_debug.h"
|
||||
#include "msm_vidc_internal.h"
|
||||
#include "msm_vidc_inst.h"
|
||||
|
||||
int msm_vidc_scale_power(struct msm_vidc_inst *inst);
|
||||
#define COMPRESSION_RATIO_MAX 5
|
||||
|
||||
enum vidc_bus_type {
|
||||
PERF,
|
||||
DDR,
|
||||
LLCC,
|
||||
};
|
||||
|
||||
/*
|
||||
* Minimum dimensions for which to calculate bandwidth.
|
||||
* This means that anything bandwidth(0, 0) ==
|
||||
* bandwidth(BASELINE_DIMENSIONS.width, BASELINE_DIMENSIONS.height)
|
||||
*/
|
||||
static const struct {
|
||||
int height, width;
|
||||
} BASELINE_DIMENSIONS = {
|
||||
.width = 1280,
|
||||
.height = 720,
|
||||
};
|
||||
|
||||
/* converts Mbps to bps (the "b" part can be bits or bytes based on context) */
|
||||
#define kbps(__mbps) ((__mbps) * 1000)
|
||||
#define bps(__mbps) (kbps(__mbps) * 1000)
|
||||
|
||||
#define GENERATE_COMPRESSION_PROFILE(__bpp, __worst) { \
|
||||
.bpp = __bpp, \
|
||||
.ratio = __worst, \
|
||||
}
|
||||
|
||||
/*
|
||||
* The below table is a structural representation of the following table:
|
||||
* Resolution | Bitrate | Compression Ratio |
|
||||
* ............|............|.........................................|
|
||||
* Width Height|Average High|Avg_8bpc Worst_8bpc Avg_10bpc Worst_10bpc|
|
||||
* 1280 720| 7 14| 1.69 1.28 1.49 1.23|
|
||||
* 1920 1080| 20 40| 1.69 1.28 1.49 1.23|
|
||||
* 2560 1440| 32 64| 2.2 1.26 1.97 1.22|
|
||||
* 3840 2160| 42 84| 2.2 1.26 1.97 1.22|
|
||||
* 4096 2160| 44 88| 2.2 1.26 1.97 1.22|
|
||||
* 4096 2304| 48 96| 2.2 1.26 1.97 1.22|
|
||||
*/
|
||||
static struct lut {
|
||||
int frame_size; /* width x height */
|
||||
int frame_rate;
|
||||
unsigned long bitrate;
|
||||
struct {
|
||||
int bpp;
|
||||
fp_t ratio;
|
||||
} compression_ratio[COMPRESSION_RATIO_MAX];
|
||||
} const LUT[] = {
|
||||
{
|
||||
.frame_size = 1280 * 720,
|
||||
.frame_rate = 30,
|
||||
.bitrate = 14,
|
||||
.compression_ratio = {
|
||||
GENERATE_COMPRESSION_PROFILE(8,
|
||||
FP(1, 28, 100)),
|
||||
GENERATE_COMPRESSION_PROFILE(10,
|
||||
FP(1, 23, 100)),
|
||||
}
|
||||
},
|
||||
{
|
||||
.frame_size = 1280 * 720,
|
||||
.frame_rate = 60,
|
||||
.bitrate = 22,
|
||||
.compression_ratio = {
|
||||
GENERATE_COMPRESSION_PROFILE(8,
|
||||
FP(1, 28, 100)),
|
||||
GENERATE_COMPRESSION_PROFILE(10,
|
||||
FP(1, 23, 100)),
|
||||
}
|
||||
},
|
||||
{
|
||||
.frame_size = 1920 * 1088,
|
||||
.frame_rate = 30,
|
||||
.bitrate = 40,
|
||||
.compression_ratio = {
|
||||
GENERATE_COMPRESSION_PROFILE(8,
|
||||
FP(1, 28, 100)),
|
||||
GENERATE_COMPRESSION_PROFILE(10,
|
||||
FP(1, 23, 100)),
|
||||
}
|
||||
},
|
||||
{
|
||||
.frame_size = 1920 * 1088,
|
||||
.frame_rate = 60,
|
||||
.bitrate = 64,
|
||||
.compression_ratio = {
|
||||
GENERATE_COMPRESSION_PROFILE(8,
|
||||
FP(1, 28, 100)),
|
||||
GENERATE_COMPRESSION_PROFILE(10,
|
||||
FP(1, 23, 100)),
|
||||
}
|
||||
},
|
||||
{
|
||||
.frame_size = 2560 * 1440,
|
||||
.frame_rate = 30,
|
||||
.bitrate = 64,
|
||||
.compression_ratio = {
|
||||
GENERATE_COMPRESSION_PROFILE(8,
|
||||
FP(1, 26, 100)),
|
||||
GENERATE_COMPRESSION_PROFILE(10,
|
||||
FP(1, 22, 100)),
|
||||
}
|
||||
},
|
||||
{
|
||||
.frame_size = 2560 * 1440,
|
||||
.frame_rate = 60,
|
||||
.bitrate = 102,
|
||||
.compression_ratio = {
|
||||
GENERATE_COMPRESSION_PROFILE(8,
|
||||
FP(1, 26, 100)),
|
||||
GENERATE_COMPRESSION_PROFILE(10,
|
||||
FP(1, 22, 100)),
|
||||
}
|
||||
},
|
||||
{
|
||||
.frame_size = 3840 * 2160,
|
||||
.frame_rate = 30,
|
||||
.bitrate = 84,
|
||||
.compression_ratio = {
|
||||
GENERATE_COMPRESSION_PROFILE(8,
|
||||
FP(1, 26, 100)),
|
||||
GENERATE_COMPRESSION_PROFILE(10,
|
||||
FP(1, 22, 100)),
|
||||
}
|
||||
},
|
||||
{
|
||||
.frame_size = 3840 * 2160,
|
||||
.frame_rate = 60,
|
||||
.bitrate = 134,
|
||||
.compression_ratio = {
|
||||
GENERATE_COMPRESSION_PROFILE(8,
|
||||
FP(1, 26, 100)),
|
||||
GENERATE_COMPRESSION_PROFILE(10,
|
||||
FP(1, 22, 100)),
|
||||
}
|
||||
},
|
||||
{
|
||||
.frame_size = 4096 * 2160,
|
||||
.frame_rate = 30,
|
||||
.bitrate = 88,
|
||||
.compression_ratio = {
|
||||
GENERATE_COMPRESSION_PROFILE(8,
|
||||
FP(1, 26, 100)),
|
||||
GENERATE_COMPRESSION_PROFILE(10,
|
||||
FP(1, 22, 100)),
|
||||
}
|
||||
},
|
||||
{
|
||||
.frame_size = 4096 * 2160,
|
||||
.frame_rate = 60,
|
||||
.bitrate = 141,
|
||||
.compression_ratio = {
|
||||
GENERATE_COMPRESSION_PROFILE(8,
|
||||
FP(1, 26, 100)),
|
||||
GENERATE_COMPRESSION_PROFILE(10,
|
||||
FP(1, 22, 100)),
|
||||
}
|
||||
},
|
||||
{
|
||||
.frame_size = 4096 * 2304,
|
||||
.frame_rate = 30,
|
||||
.bitrate = 96,
|
||||
.compression_ratio = {
|
||||
GENERATE_COMPRESSION_PROFILE(8,
|
||||
FP(1, 26, 100)),
|
||||
GENERATE_COMPRESSION_PROFILE(10,
|
||||
FP(1, 22, 100)),
|
||||
}
|
||||
},
|
||||
{
|
||||
.frame_size = 4096 * 2304,
|
||||
.frame_rate = 60,
|
||||
.bitrate = 154,
|
||||
.compression_ratio = {
|
||||
GENERATE_COMPRESSION_PROFILE(8,
|
||||
FP(1, 26, 100)),
|
||||
GENERATE_COMPRESSION_PROFILE(10,
|
||||
FP(1, 22, 100)),
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
static inline u32 get_type_frm_name(const char* name)
|
||||
{
|
||||
if (!strcmp(name, "venus-llcc"))
|
||||
return LLCC;
|
||||
else if (!strcmp(name, "venus-ddr"))
|
||||
return DDR;
|
||||
else
|
||||
return PERF;
|
||||
}
|
||||
|
||||
#define DUMP_HEADER_MAGIC 0xdeadbeef
|
||||
#define DUMP_FP_FMT "%FP" /* special format for fp_t */
|
||||
|
||||
struct dump {
|
||||
char* key;
|
||||
char* format;
|
||||
size_t val;
|
||||
};
|
||||
|
||||
struct lut const* __lut(int width, int height, int fps);
|
||||
fp_t __compression_ratio(struct lut const* entry, int bpp);
|
||||
void __dump(struct dump dump[], int len);
|
||||
|
||||
static inline bool __ubwc(enum msm_vidc_colorformat_type f)
|
||||
{
|
||||
switch (f) {
|
||||
case MSM_VIDC_FMT_NV12_UBWC:
|
||||
case MSM_VIDC_FMT_NV12_TP10_UBWC:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static inline int __bpp(enum msm_vidc_colorformat_type f)
|
||||
{
|
||||
switch (f) {
|
||||
case MSM_VIDC_FMT_NV12:
|
||||
case MSM_VIDC_FMT_NV21:
|
||||
case MSM_VIDC_FMT_NV12_UBWC:
|
||||
case MSM_VIDC_FMT_RGBA8888_UBWC:
|
||||
return 8;
|
||||
case MSM_VIDC_FMT_NV12_P010:
|
||||
case MSM_VIDC_FMT_NV12_TP10_UBWC:
|
||||
return 10;
|
||||
default:
|
||||
d_vpr_e("Unsupported colorformat (%x)", f);
|
||||
return INT_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
u64 msm_vidc_max_freq(struct msm_vidc_inst* inst);
|
||||
int msm_vidc_get_inst_load(struct msm_vidc_inst* inst,
|
||||
enum load_calc_quirks quirks);
|
||||
int msm_vidc_scale_power(struct msm_vidc_inst *inst, bool scale_buses);
|
||||
|
||||
#endif
|
||||
|
@@ -67,7 +67,7 @@ int venus_hfi_core_init(struct msm_vidc_core *core);
|
||||
int venus_hfi_core_release(struct msm_vidc_core *core);
|
||||
int venus_hfi_suspend(struct msm_vidc_core *core);
|
||||
int venus_hfi_scale_clocks(struct msm_vidc_inst* inst, u64 freq);
|
||||
int venus_hfi_scale_buses(struct msm_vidc_inst* inst, u64 freq);
|
||||
int venus_hfi_scale_buses(struct msm_vidc_inst* inst, u64 bw_ddr, u64 bw_llcc);
|
||||
|
||||
void venus_hfi_work_handler(struct work_struct *work);
|
||||
void venus_hfi_pm_work_handler(struct work_struct *work);
|
||||
|
Referência em uma nova issue
Block a user