blob: 8cd3214674d5faf984c017a1dfb22ec954014cad [file] [log] [blame]
Jing Zhou076a3092017-02-27 02:43:03 -08001/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#ifndef _CAM_SUBDEV_H_
14#define _CAM_SUBDEV_H_
15
16#include <linux/types.h>
17#include <linux/platform_device.h>
18#include <media/v4l2-fh.h>
19#include <media/v4l2-device.h>
20#include <media/v4l2-subdev.h>
21#include <media/v4l2-event.h>
22#include <media/v4l2-ioctl.h>
23
24#define CAM_SUBDEVICE_EVENT_MAX 30
25
26/**
27 * struct cam_subdev - describes a camera sub-device
28 *
29 * @pdev: Pointer to the platform device
30 * @sd: V4l2 subdevice
31 * @ops: V4l2 subdecie operations
32 * @internal_ops: V4l2 subdevice internal operations
33 * @name: Name of the sub-device. Please notice that the name
34 * must be unique.
35 * @sd_flags: Subdev flags. Can be:
36 * %V4L2_SUBDEV_FL_HAS_DEVNODE - Set this flag if
37 * this subdev needs a device node.
38 * %V4L2_SUBDEV_FL_HAS_EVENTS - Set this flag if
39 * this subdev generates events.
40 * @token: Pointer to cookie of the client driver
41 * @ent_function: Media entity function type. Can be:
42 * %CAM_IFE_DEVICE_TYPE - identifies as IFE device.
43 * %CAM_ICP_DEVICE_TYPE - identifies as ICP device.
44 *
45 * Each instance of a subdev driver should create this struct, either
46 * stand-alone or embedded in a larger struct. This structure should be
47 * initialized/registered by cam_register_subdev
48 *
49 */
50struct cam_subdev {
51 struct platform_device *pdev;
52 struct v4l2_subdev sd;
53 const struct v4l2_subdev_ops *ops;
54 const struct v4l2_subdev_internal_ops *internal_ops;
55 char *name;
56 u32 sd_flags;
57 void *token;
58 u32 ent_function;
59};
60
61/**
62 * cam_subdev_probe()
63 *
64 * @brief: Camera Subdevice node probe function for v4l2 setup
65 *
66 * @sd: Camera subdevice object
67 * @name: Name of the subdevice node
68 * @dev_type: Subdevice node type
69 *
70 */
71int cam_subdev_probe(struct cam_subdev *sd, struct platform_device *pdev,
72 char *name, uint32_t dev_type);
73
74/**
75 * cam_subdev_remove()
76 *
77 * @brief: Called when subdevice node is unloaded
78 *
79 * @sd: Camera subdevice node object
80 *
81 */
82int cam_subdev_remove(struct cam_subdev *sd);
83
84/**
Viswanadha Raju Thotakura08b50812017-08-25 14:52:32 -070085 * cam_register_subdev_fops()
86 *
87 * @brief: This common utility function assigns subdev ops
88 *
89 * @fops: v4l file operations
90 */
91void cam_register_subdev_fops(struct v4l2_file_operations *fops);
92
93/**
Jing Zhou076a3092017-02-27 02:43:03 -080094 * cam_register_subdev()
95 *
96 * @brief: This is the common utility function to be called by each camera
97 * subdevice node when it tries to register itself to the camera
98 * request manager
99 *
100 * @sd: Pointer to struct cam_subdev.
101 */
102int cam_register_subdev(struct cam_subdev *sd);
103
104/**
105 * cam_unregister_subdev()
106 *
107 * @brief: This is the common utility function to be called by each camera
108 * subdevice node when it tries to unregister itself from the
109 * camera request manger
110 *
111 * @sd: Pointer to struct cam_subdev.
112 */
113int cam_unregister_subdev(struct cam_subdev *sd);
114
115#endif /* _CAM_SUBDEV_H_ */