linux/drivers/media/v4l2-core/v4l2-compat-ioctl32.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * ioctl32.c: Conversion between 32bit and 64bit native ioctls.
 *	Separated from fs stuff by Arnd Bergmann <[email protected]>
 *
 * Copyright (C) 1997-2000  Jakub Jelinek  ([email protected])
 * Copyright (C) 1998  Eddie C. Dost  ([email protected])
 * Copyright (C) 2001,2002  Andi Kleen, SuSE Labs
 * Copyright (C) 2003       Pavel Machek ([email protected])
 * Copyright (C) 2005       Philippe De Muyter ([email protected])
 * Copyright (C) 2008       Hans Verkuil <[email protected]>
 *
 * These routines maintain argument size conversion between 32bit and 64bit
 * ioctls.
 */

#include <linux/compat.h>
#include <linux/module.h>
#include <linux/videodev2.h>
#include <linux/v4l2-subdev.h>
#include <media/v4l2-dev.h>
#include <media/v4l2-fh.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-ioctl.h>

/*
 * Per-ioctl data copy handlers.
 *
 * Those come in pairs, with a get_v4l2_foo() and a put_v4l2_foo() routine,
 * where "v4l2_foo" is the name of the V4L2 struct.
 *
 * They basically get two __user pointers, one with a 32-bits struct that
 * came from the userspace call and a 64-bits struct, also allocated as
 * userspace, but filled internally by do_video_ioctl().
 *
 * For ioctls that have pointers inside it, the functions will also
 * receive an ancillary buffer with extra space, used to pass extra
 * data to the routine.
 */

struct v4l2_window32 {};

static int get_v4l2_window32(struct v4l2_window *p64,
			     struct v4l2_window32 __user *p32)
{}

static int put_v4l2_window32(struct v4l2_window *p64,
			     struct v4l2_window32 __user *p32)
{}

struct v4l2_format32 {};

/**
 * struct v4l2_create_buffers32 - VIDIOC_CREATE_BUFS32 argument
 * @index:	on return, index of the first created buffer
 * @count:	entry: number of requested buffers,
 *		return: number of created buffers
 * @memory:	buffer memory type
 * @format:	frame format, for which buffers are requested
 * @capabilities: capabilities of this buffer type.
 * @flags:	additional buffer management attributes (ignored unless the
 *		queue has V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS capability and
 *		configured for MMAP streaming I/O).
 * @max_num_buffers: if V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS capability flag is set
 *		this field indicate the maximum possible number of buffers
 *		for this queue.
 * @reserved:	future extensions
 */
struct v4l2_create_buffers32 {};

static int get_v4l2_format32(struct v4l2_format *p64,
			     struct v4l2_format32 __user *p32)
{}

static int get_v4l2_create32(struct v4l2_create_buffers *p64,
			     struct v4l2_create_buffers32 __user *p32)
{}

static int put_v4l2_format32(struct v4l2_format *p64,
			     struct v4l2_format32 __user *p32)
{}

static int put_v4l2_create32(struct v4l2_create_buffers *p64,
			     struct v4l2_create_buffers32 __user *p32)
{}

struct v4l2_standard32 {};

static int get_v4l2_standard32(struct v4l2_standard *p64,
			       struct v4l2_standard32 __user *p32)
{}

static int put_v4l2_standard32(struct v4l2_standard *p64,
			       struct v4l2_standard32 __user *p32)
{}

struct v4l2_plane32 {};

/*
 * This is correct for all architectures including i386, but not x32,
 * which has different alignment requirements for timestamp
 */
struct v4l2_buffer32 {};

#ifdef CONFIG_COMPAT_32BIT_TIME
struct v4l2_buffer32_time32 {};
#endif

static int get_v4l2_plane32(struct v4l2_plane *p64,
			    struct v4l2_plane32 __user *p32,
			    enum v4l2_memory memory)
{}

static int put_v4l2_plane32(struct v4l2_plane *p64,
			    struct v4l2_plane32 __user *p32,
			    enum v4l2_memory memory)
{}

static int get_v4l2_buffer32(struct v4l2_buffer *vb,
			     struct v4l2_buffer32 __user *arg)
{}

#ifdef CONFIG_COMPAT_32BIT_TIME
static int get_v4l2_buffer32_time32(struct v4l2_buffer *vb,
				    struct v4l2_buffer32_time32 __user *arg)
{}
#endif

static int put_v4l2_buffer32(struct v4l2_buffer *vb,
			     struct v4l2_buffer32 __user *arg)
{}

#ifdef CONFIG_COMPAT_32BIT_TIME
static int put_v4l2_buffer32_time32(struct v4l2_buffer *vb,
				    struct v4l2_buffer32_time32 __user *arg)
{}
#endif

struct v4l2_framebuffer32 {};

static int get_v4l2_framebuffer32(struct v4l2_framebuffer *p64,
				  struct v4l2_framebuffer32 __user *p32)
{}

static int put_v4l2_framebuffer32(struct v4l2_framebuffer *p64,
				  struct v4l2_framebuffer32 __user *p32)
{}

struct v4l2_input32 {};

/*
 * The 64-bit v4l2_input struct has extra padding at the end of the struct.
 * Otherwise it is identical to the 32-bit version.
 */
static inline int get_v4l2_input32(struct v4l2_input *p64,
				   struct v4l2_input32 __user *p32)
{}

static inline int put_v4l2_input32(struct v4l2_input *p64,
				   struct v4l2_input32 __user *p32)
{}

struct v4l2_ext_controls32 {};

struct v4l2_ext_control32 {} __attribute__ ((packed));

/* Return true if this control is a pointer type. */
static inline bool ctrl_is_pointer(struct file *file, u32 id)
{}

static int get_v4l2_ext_controls32(struct v4l2_ext_controls *p64,
				   struct v4l2_ext_controls32 __user *p32)
{}

static int put_v4l2_ext_controls32(struct v4l2_ext_controls *p64,
				   struct v4l2_ext_controls32 __user *p32)
{}

#ifdef CONFIG_X86_64
/*
 * x86 is the only compat architecture with different struct alignment
 * between 32-bit and 64-bit tasks.
 */
struct v4l2_event32 {};

static int put_v4l2_event32(struct v4l2_event *p64,
			    struct v4l2_event32 __user *p32)
{}

#endif

#ifdef CONFIG_COMPAT_32BIT_TIME
struct v4l2_event32_time32 {};

static int put_v4l2_event32_time32(struct v4l2_event *p64,
				   struct v4l2_event32_time32 __user *p32)
{}
#endif

struct v4l2_edid32 {};

static int get_v4l2_edid32(struct v4l2_edid *p64,
			   struct v4l2_edid32 __user *p32)
{}

static int put_v4l2_edid32(struct v4l2_edid *p64,
			   struct v4l2_edid32 __user *p32)
{}

/*
 * List of ioctls that require 32-bits/64-bits conversion
 *
 * The V4L2 ioctls that aren't listed there don't have pointer arguments
 * and the struct size is identical for both 32 and 64 bits versions, so
 * they don't need translations.
 */

#define VIDIOC_G_FMT32
#define VIDIOC_S_FMT32
#define VIDIOC_QUERYBUF32
#define VIDIOC_G_FBUF32
#define VIDIOC_S_FBUF32
#define VIDIOC_QBUF32
#define VIDIOC_DQBUF32
#define VIDIOC_ENUMSTD32
#define VIDIOC_ENUMINPUT32
#define VIDIOC_G_EDID32
#define VIDIOC_S_EDID32
#define VIDIOC_TRY_FMT32
#define VIDIOC_G_EXT_CTRLS32
#define VIDIOC_S_EXT_CTRLS32
#define VIDIOC_TRY_EXT_CTRLS32
#define VIDIOC_DQEVENT32
#define VIDIOC_CREATE_BUFS32
#define VIDIOC_PREPARE_BUF32

#ifdef CONFIG_COMPAT_32BIT_TIME
#define VIDIOC_QUERYBUF32_TIME32
#define VIDIOC_QBUF32_TIME32
#define VIDIOC_DQBUF32_TIME32
#define VIDIOC_DQEVENT32_TIME32
#define VIDIOC_PREPARE_BUF32_TIME32
#endif

unsigned int v4l2_compat_translate_cmd(unsigned int cmd)
{}

int v4l2_compat_get_user(void __user *arg, void *parg, unsigned int cmd)
{}

int v4l2_compat_put_user(void __user *arg, void *parg, unsigned int cmd)
{}

int v4l2_compat_get_array_args(struct file *file, void *mbuf,
			       void __user *user_ptr, size_t array_size,
			       unsigned int cmd, void *arg)
{}

int v4l2_compat_put_array_args(struct file *file, void __user *user_ptr,
			       void *mbuf, size_t array_size,
			       unsigned int cmd, void *arg)
{}

/**
 * v4l2_compat_ioctl32() - Handles a compat32 ioctl call
 *
 * @file: pointer to &struct file with the file handler
 * @cmd: ioctl to be called
 * @arg: arguments passed from/to the ioctl handler
 *
 * This function is meant to be used as .compat_ioctl fops at v4l2-dev.c
 * in order to deal with 32-bit calls on a 64-bits Kernel.
 *
 * This function calls do_video_ioctl() for non-private V4L2 ioctls.
 * If the function is a private one it calls vdev->fops->compat_ioctl32
 * instead.
 */
long v4l2_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg)
{}
EXPORT_SYMBOL_GPL();