Skip to content

bcm2835_isp fixes for const'ness #3592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 18 additions & 51 deletions drivers/staging/vc04_services/bcm2835-isp/bcm2835-v4l2-isp.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ struct bcm2835_isp_q_data {
unsigned int width;
unsigned int height;
unsigned int sizeimage;
struct bcm2835_isp_fmt *fmt;
const struct bcm2835_isp_fmt *fmt;
};

/*
Expand Down Expand Up @@ -232,20 +232,21 @@ struct bcm2835_isp_fmt *find_format_by_fourcc(unsigned int fourcc,
struct bcm2835_isp_node *node)
{
struct bcm2835_isp_fmt_list *fmts = &node->supported_fmts;
struct bcm2835_isp_fmt *fmt;
const struct bcm2835_isp_fmt *fmt;
unsigned int i;

for (i = 0; i < fmts->num_entries; i++) {
fmt = &fmts->list[i];
fmt = fmts->list[i];
if (fmt->fourcc == fourcc)
return fmt;
}

return NULL;
}

static struct bcm2835_isp_fmt *find_format(struct v4l2_format *f,
struct bcm2835_isp_node *node)
static const
struct bcm2835_isp_fmt *find_format(struct v4l2_format *f,
struct bcm2835_isp_node *node)
{
return find_format_by_fourcc(node_is_stats(node) ?
f->fmt.meta.dataformat :
Expand Down Expand Up @@ -666,19 +667,20 @@ static const struct vb2_ops bcm2835_isp_node_queue_ops = {
.stop_streaming = bcm2835_isp_node_stop_streaming,
};

static struct bcm2835_isp_fmt *get_default_format(struct bcm2835_isp_node *node)
static const
struct bcm2835_isp_fmt *get_default_format(struct bcm2835_isp_node *node)
{
return &node->supported_fmts.list[0];
return node->supported_fmts.list[0];
}

static inline unsigned int get_bytesperline(int width,
struct bcm2835_isp_fmt *fmt)
const struct bcm2835_isp_fmt *fmt)
{
return ALIGN((width * fmt->depth) >> 3, fmt->bytesperline_align);
}

static inline unsigned int get_sizeimage(int bpl, int width, int height,
struct bcm2835_isp_fmt *fmt)
const struct bcm2835_isp_fmt *fmt)
{
return (bpl * height * fmt->size_multiplier_x2) >> 1;
}
Expand Down Expand Up @@ -892,8 +894,8 @@ static int bcm2835_isp_node_enum_fmt(struct file *file, void *priv,

if (f->index < fmts->num_entries) {
/* Format found */
f->pixelformat = fmts->list[f->index].fourcc;
f->flags = fmts->list[f->index].flags;
f->pixelformat = fmts->list[f->index]->fourcc;
f->flags = fmts->list[f->index]->flags;
return 0;
}

Expand All @@ -905,7 +907,7 @@ static int bcm2835_isp_enum_framesizes(struct file *file, void *priv,
{
struct bcm2835_isp_node *node = video_drvdata(file);
struct bcm2835_isp_dev *dev = node_get_dev(node);
struct bcm2835_isp_fmt *fmt;
const struct bcm2835_isp_fmt *fmt;

if (node_is_stats(node) || fsize->index)
return -EINVAL;
Expand Down Expand Up @@ -933,7 +935,7 @@ static int bcm2835_isp_node_try_fmt(struct file *file, void *priv,
struct v4l2_format *f)
{
struct bcm2835_isp_node *node = video_drvdata(file);
struct bcm2835_isp_fmt *fmt;
const struct bcm2835_isp_fmt *fmt;

if (f->type != node->queue.type)
return -EINVAL;
Expand Down Expand Up @@ -1113,7 +1115,7 @@ static const struct v4l2_ioctl_ops bcm2835_isp_node_ioctl_ops = {
static int bcm2835_isp_get_supported_fmts(struct bcm2835_isp_node *node)
{
struct bcm2835_isp_dev *dev = node_get_dev(node);
struct bcm2835_isp_fmt *list;
struct bcm2835_isp_fmt const **list;
unsigned int i, j, num_encodings;
u32 fourccs[MAX_SUPPORTED_ENCODINGS];
u32 param_size = sizeof(fourccs);
Expand Down Expand Up @@ -1144,7 +1146,7 @@ static int bcm2835_isp_get_supported_fmts(struct bcm2835_isp_node *node)
* Any that aren't supported will waste a very small amount of memory.
*/
list = devm_kzalloc(dev->dev,
sizeof(struct bcm2835_isp_fmt) * num_encodings,
sizeof(struct bcm2835_isp_fmt *) * num_encodings,
GFP_KERNEL);
if (!list)
return -ENOMEM;
Expand All @@ -1154,47 +1156,12 @@ static int bcm2835_isp_get_supported_fmts(struct bcm2835_isp_node *node)
const struct bcm2835_isp_fmt *fmt = get_fmt(fourccs[i]);

if (fmt) {
list[j] = *fmt;
list[j] = fmt;
j++;
}
}
node->supported_fmts.num_entries = j;

param_size = sizeof(fourccs);
ret = vchiq_mmal_port_parameter_get(dev->mmal_instance,
get_port_data(node),
MMAL_PARAMETER_SUPPORTED_ENCODINGS,
&fourccs, &param_size);

if (ret) {
if (ret == MMAL_MSG_STATUS_ENOSPC) {
v4l2_err(&dev->v4l2_dev,
"%s: port has more encoding than we provided space for. Some are dropped.\n",
__func__);
num_encodings = MAX_SUPPORTED_ENCODINGS;
} else {
return -EINVAL;
}
} else {
num_encodings = param_size / sizeof(u32);
}
/* Assume at this stage that all encodings will be supported in V4L2. */
list = devm_kzalloc(dev->dev,
sizeof(struct bcm2835_isp_fmt) * num_encodings,
GFP_KERNEL);
if (!list)
return -ENOMEM;
node->supported_fmts.list = list;

for (i = 0, j = 0; i < num_encodings; i++) {
const struct bcm2835_isp_fmt *fmt = get_fmt(fourccs[i]);

if (fmt) {
list[j] = *fmt;
j++;
}
}
node->supported_fmts.num_entries = j;
return 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct bcm2835_isp_fmt {
};

struct bcm2835_isp_fmt_list {
struct bcm2835_isp_fmt *list;
struct bcm2835_isp_fmt const **list;
unsigned int num_entries;
};

Expand Down