media: bdisp: Access v4l2_fh from file
The v4l2_fh associated with an open file handle is now guaranteed to be available in file->private_data, initialised by v4l2_fh_add(). Access the v4l2_fh, and from there the driver-specific structure, from the file * in all ioctl handlers. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Co-developed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
This commit is contained in:
committed by
Hans Verkuil
parent
fede1dac71
commit
c3db0cdea4
@@ -33,11 +33,9 @@
|
||||
#define BDISP_MIN_H 1
|
||||
#define BDISP_MAX_H 8191
|
||||
|
||||
#define fh_to_ctx(__fh) container_of(__fh, struct bdisp_ctx, fh)
|
||||
|
||||
static inline struct bdisp_ctx *file_to_ctx(struct file *filp)
|
||||
{
|
||||
return fh_to_ctx(file_to_v4l2_fh(filp));
|
||||
return container_of(file_to_v4l2_fh(filp), struct bdisp_ctx, fh);
|
||||
}
|
||||
|
||||
enum bdisp_dev_flags {
|
||||
@@ -686,7 +684,7 @@ static const struct v4l2_file_operations bdisp_fops = {
|
||||
static int bdisp_querycap(struct file *file, void *fh,
|
||||
struct v4l2_capability *cap)
|
||||
{
|
||||
struct bdisp_ctx *ctx = fh_to_ctx(fh);
|
||||
struct bdisp_ctx *ctx = file_to_ctx(file);
|
||||
struct bdisp_dev *bdisp = ctx->bdisp_dev;
|
||||
|
||||
strscpy(cap->driver, bdisp->pdev->name, sizeof(cap->driver));
|
||||
@@ -698,7 +696,7 @@ static int bdisp_querycap(struct file *file, void *fh,
|
||||
|
||||
static int bdisp_enum_fmt(struct file *file, void *fh, struct v4l2_fmtdesc *f)
|
||||
{
|
||||
struct bdisp_ctx *ctx = fh_to_ctx(fh);
|
||||
struct bdisp_ctx *ctx = file_to_ctx(file);
|
||||
const struct bdisp_fmt *fmt;
|
||||
|
||||
if (f->index >= ARRAY_SIZE(bdisp_formats))
|
||||
@@ -718,7 +716,7 @@ static int bdisp_enum_fmt(struct file *file, void *fh, struct v4l2_fmtdesc *f)
|
||||
|
||||
static int bdisp_g_fmt(struct file *file, void *fh, struct v4l2_format *f)
|
||||
{
|
||||
struct bdisp_ctx *ctx = fh_to_ctx(fh);
|
||||
struct bdisp_ctx *ctx = file_to_ctx(file);
|
||||
struct v4l2_pix_format *pix;
|
||||
struct bdisp_frame *frame = ctx_get_frame(ctx, f->type);
|
||||
|
||||
@@ -742,7 +740,7 @@ static int bdisp_g_fmt(struct file *file, void *fh, struct v4l2_format *f)
|
||||
|
||||
static int bdisp_try_fmt(struct file *file, void *fh, struct v4l2_format *f)
|
||||
{
|
||||
struct bdisp_ctx *ctx = fh_to_ctx(fh);
|
||||
struct bdisp_ctx *ctx = file_to_ctx(file);
|
||||
struct v4l2_pix_format *pix = &f->fmt.pix;
|
||||
const struct bdisp_fmt *format;
|
||||
u32 in_w, in_h;
|
||||
@@ -792,7 +790,7 @@ static int bdisp_try_fmt(struct file *file, void *fh, struct v4l2_format *f)
|
||||
|
||||
static int bdisp_s_fmt(struct file *file, void *fh, struct v4l2_format *f)
|
||||
{
|
||||
struct bdisp_ctx *ctx = fh_to_ctx(fh);
|
||||
struct bdisp_ctx *ctx = file_to_ctx(file);
|
||||
struct vb2_queue *vq;
|
||||
struct bdisp_frame *frame;
|
||||
struct v4l2_pix_format *pix;
|
||||
@@ -845,8 +843,8 @@ static int bdisp_s_fmt(struct file *file, void *fh, struct v4l2_format *f)
|
||||
static int bdisp_g_selection(struct file *file, void *fh,
|
||||
struct v4l2_selection *s)
|
||||
{
|
||||
struct bdisp_ctx *ctx = file_to_ctx(file);
|
||||
struct bdisp_frame *frame;
|
||||
struct bdisp_ctx *ctx = fh_to_ctx(fh);
|
||||
|
||||
frame = ctx_get_frame(ctx, s->type);
|
||||
if (IS_ERR(frame)) {
|
||||
@@ -923,8 +921,8 @@ static int is_rect_enclosed(struct v4l2_rect *a, struct v4l2_rect *b)
|
||||
static int bdisp_s_selection(struct file *file, void *fh,
|
||||
struct v4l2_selection *s)
|
||||
{
|
||||
struct bdisp_ctx *ctx = file_to_ctx(file);
|
||||
struct bdisp_frame *frame;
|
||||
struct bdisp_ctx *ctx = fh_to_ctx(fh);
|
||||
struct v4l2_rect *in, out;
|
||||
bool valid = false;
|
||||
|
||||
@@ -1001,7 +999,7 @@ static int bdisp_s_selection(struct file *file, void *fh,
|
||||
|
||||
static int bdisp_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
|
||||
{
|
||||
struct bdisp_ctx *ctx = fh_to_ctx(fh);
|
||||
struct bdisp_ctx *ctx = file_to_ctx(file);
|
||||
|
||||
if ((type == V4L2_BUF_TYPE_VIDEO_OUTPUT) &&
|
||||
!bdisp_ctx_state_is_set(BDISP_SRC_FMT, ctx)) {
|
||||
|
||||
Reference in New Issue
Block a user