Skip to content

Commit

Permalink
msm: camera: isp: Add fps Blob support
Browse files Browse the repository at this point in the history
Add fps blob to get the fps value from user space. Epoch interrupt
configuration will be depend on the fps value. Configure epoch
interrupt to half of the frame if fps value is 60, in rest all cases
configure epoch interrupt to 2/3 of the frame.

Change-Id: I2544a5e18895a983155c2f01e49920c9e1ec59b9
Signed-off-by: Chandan Kumar Jha <[email protected]>
  • Loading branch information
Chandan Kumar Jha committed Jul 25, 2019
1 parent cb1a16e commit 5def64c
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3198,6 +3198,54 @@ static int cam_isp_blob_fe_update(
return rc;
}

static int cam_isp_blob_fps_config(
uint32_t blob_type,
struct cam_isp_generic_blob_info *blob_info,
struct cam_fps_config *fps_config,
struct cam_hw_prepare_update_args *prepare)
{
struct cam_ife_hw_mgr_ctx *ctx = NULL;
struct cam_ife_hw_mgr_res *hw_mgr_res;
struct cam_hw_intf *hw_intf;
struct cam_vfe_fps_config_args fps_config_args;
int rc = -EINVAL;
uint32_t i;

ctx = prepare->ctxt_to_hw_map;

list_for_each_entry(hw_mgr_res, &ctx->res_list_ife_src, list) {
for (i = 0; i < CAM_ISP_HW_SPLIT_MAX; i++) {
if (!hw_mgr_res->hw_res[i])
continue;

if (hw_mgr_res->res_id == CAM_ISP_HW_VFE_IN_CAMIF) {
hw_intf = hw_mgr_res->hw_res[i]->hw_intf;
if (hw_intf && hw_intf->hw_ops.process_cmd) {
fps_config_args.fps =
fps_config->fps;
fps_config_args.node_res =
hw_mgr_res->hw_res[i];

rc = hw_intf->hw_ops.process_cmd(
hw_intf->hw_priv,
CAM_ISP_HW_CMD_FPS_CONFIG,
&fps_config_args,
sizeof(
struct cam_vfe_fps_config_args)
);
if (rc)
CAM_ERR(CAM_ISP,
"Failed fps config:%d",
fps_config->fps);
} else
CAM_WARN(CAM_ISP, "NULL hw_intf!");
}
}
}

return rc;
}

static int cam_isp_blob_ubwc_update(
uint32_t blob_type,
struct cam_isp_generic_blob_info *blob_info,
Expand Down Expand Up @@ -3742,7 +3790,6 @@ static int cam_isp_packet_generic_blob_handler(void *user_data,
return -EINVAL;
}

CAM_DBG(CAM_ISP, "FS2: BLOB Type: %d", blob_type);
switch (blob_type) {
case CAM_ISP_GENERIC_BLOB_TYPE_HFR_CONFIG: {
struct cam_isp_resource_hfr_config *hfr_config;
Expand Down Expand Up @@ -3995,6 +4042,24 @@ static int cam_isp_packet_generic_blob_handler(void *user_data,
if (rc)
CAM_ERR(CAM_ISP,
"Sensor Dimension Update Failed rc: %d", rc);
}
break;
case CAM_ISP_GENERIC_BLOB_TYPE_FPS_CONFIG: {
struct cam_fps_config *fps_config;

if (blob_size < sizeof(struct cam_fps_config)) {
CAM_ERR(CAM_ISP, "Invalid fps blob size %u expected %u",
blob_size, sizeof(struct cam_fps_config));
return -EINVAL;
}

fps_config = (struct cam_fps_config *)blob_data;

rc = cam_isp_blob_fps_config(blob_type, blob_info,
fps_config, prepare);
if (rc)
CAM_ERR(CAM_ISP, "FPS Update Failed rc: %d", rc);

}
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include "cam_irq_controller.h"
#include <uapi/media/cam_isp.h>

#define CAM_ISP_FPS_60 60

/*
* struct cam_isp_timestamp:
*
Expand Down Expand Up @@ -105,6 +107,7 @@ enum cam_isp_hw_cmd_type {
CAM_ISP_HW_CMD_FE_UPDATE_IN_RD,
CAM_ISP_HW_CMD_FE_UPDATE_BUS_RD,
CAM_ISP_HW_CMD_GET_IRQ_REGISTER_DUMP,
CAM_ISP_HW_CMD_FPS_CONFIG,
CAM_ISP_HW_CMD_MAX,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,17 @@ struct cam_vfe_clock_update_args {
uint64_t clk_rate;
};

/*
* struct cam_vfe_fps_config_args:
*
* @node_res: Resource to get the fps value
* @fps: FPS value to configure EPOCH
*/
struct cam_vfe_fps_config_args {
struct cam_isp_resource_node *node_res;
uint32_t fps;
};

/*
* struct cam_vfe_bw_update_args:
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,7 @@ int cam_vfe_process_cmd(void *hw_priv, uint32_t cmd_type,
case CAM_ISP_HW_CMD_BW_UPDATE:
case CAM_ISP_HW_CMD_BW_CONTROL:
case CAM_ISP_HW_CMD_GET_IRQ_REGISTER_DUMP:
case CAM_ISP_HW_CMD_FPS_CONFIG:
rc = core_info->vfe_top->hw_ops.process_cmd(
core_info->vfe_top->top_priv, cmd_type, cmd_args,
arg_size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ struct cam_vfe_mux_camif_data {
bool enable_sof_irq_debug;
uint32_t irq_debug_cnt;
uint32_t camif_debug;
uint32_t fps;
};

static int cam_vfe_camif_validate_pix_pattern(uint32_t pattern)
Expand Down Expand Up @@ -269,9 +270,15 @@ static int cam_vfe_camif_resource_start(
rsrc_data->camif_reg->epoch_irq);
break;
default:
epoch0_irq_mask = ((rsrc_data->last_line -
if (rsrc_data->fps == CAM_ISP_FPS_60) {
epoch0_irq_mask = ((rsrc_data->last_line -
rsrc_data->first_line) / 2) +
rsrc_data->first_line;
} else {
epoch0_irq_mask = (((rsrc_data->last_line -
rsrc_data->first_line) * 2) / 3) +
rsrc_data->first_line;
}
epoch1_irq_mask = rsrc_data->reg_data->epoch_line_cfg &
0xFFFF;
computed_epoch_line_cfg = (epoch0_irq_mask << 16) |
Expand Down Expand Up @@ -515,6 +522,20 @@ static int cam_vfe_camif_sof_irq_debug(

return 0;
}
static int cam_vfe_camif_set_fps_config(
struct cam_isp_resource_node *rsrc_node, void *cmd_args)
{
struct cam_vfe_mux_camif_data *camif_priv = NULL;
struct cam_vfe_fps_config_args *fps_args = cmd_args;

camif_priv =
(struct cam_vfe_mux_camif_data *)rsrc_node->res_priv;

camif_priv->fps = fps_args->fps;

return 0;

}

static int cam_vfe_camif_process_cmd(struct cam_isp_resource_node *rsrc_node,
uint32_t cmd_type, void *cmd_args, uint32_t arg_size)
Expand Down Expand Up @@ -546,6 +567,9 @@ static int cam_vfe_camif_process_cmd(struct cam_isp_resource_node *rsrc_node,
case CAM_ISP_HW_CMD_GET_IRQ_REGISTER_DUMP:
rc = cam_vfe_camif_irq_reg_dump(rsrc_node);
break;
case CAM_ISP_HW_CMD_FPS_CONFIG:
rc = cam_vfe_camif_set_fps_config(rsrc_node, cmd_args);
break;
default:
CAM_ERR(CAM_ISP,
"unsupported process command:%d", cmd_type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,22 @@ static int cam_vfe_top_fs_update(
return 0;
}

static int cam_vfe_top_fps_config(
struct cam_vfe_top_ver2_priv *top_priv,
void *cmd_args, uint32_t arg_size)
{
struct cam_vfe_fps_config_args *cmd_update = NULL;

cmd_update =
(struct cam_vfe_fps_config_args *)cmd_args;

if (cmd_update->node_res->process_cmd)
return cmd_update->node_res->process_cmd(cmd_update->node_res,
CAM_ISP_HW_CMD_FPS_CONFIG, cmd_args, arg_size);

return 0;
}

static int cam_vfe_top_clock_update(
struct cam_vfe_top_ver2_priv *top_priv,
void *cmd_args, uint32_t arg_size)
Expand Down Expand Up @@ -740,6 +756,10 @@ int cam_vfe_top_process_cmd(void *device_priv, uint32_t cmd_type,
rc = cam_vfe_get_irq_register_dump(top_priv,
cmd_args, arg_size);
break;
case CAM_ISP_HW_CMD_FPS_CONFIG:
rc = cam_vfe_top_fps_config(top_priv, cmd_args,
arg_size);
break;
default:
rc = -EINVAL;
CAM_ERR(CAM_ISP, "Error! Invalid cmd:%d", cmd_type);
Expand Down
10 changes: 10 additions & 0 deletions include/uapi/media/cam_isp.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
#define CAM_ISP_GENERIC_BLOB_TYPE_BW_CONFIG_V2 6
#define CAM_ISP_GENERIC_BLOB_TYPE_INIT_FRAME_DROP 10
#define CAM_ISP_GENERIC_BLOB_TYPE_SENSOR_DIMENSION_CONFIG 11
#define CAM_ISP_GENERIC_BLOB_TYPE_FPS_CONFIG 12

/* Per Path Usage Data */
#define CAM_ISP_USAGE_INVALID 0
Expand Down Expand Up @@ -520,6 +521,15 @@ struct cam_isp_acquire_hw_info {
uint64_t data;
};

/**
* struct cam_fps_config - FPS blob support
*
* @fps: FPS value
*/
struct cam_fps_config {
uint32_t fps;
} __attribute__((packed));

#define CAM_ISP_ACQUIRE_COMMON_VER0 0x1000

#define CAM_ISP_ACQUIRE_COMMON_SIZE_VER0 0x0
Expand Down

1 comment on commit 5def64c

@stefanhh0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit is already included in the commit with the ID: f5d777a

Please sign in to comment.