Linux Audio

Check our new training course

Loading...
v5.9
  1/* SPDX-License-Identifier: GPL-2.0-only */
  2/*
  3 * ispstat.h
  4 *
  5 * TI OMAP3 ISP - Statistics core
  6 *
  7 * Copyright (C) 2010 Nokia Corporation
  8 * Copyright (C) 2009 Texas Instruments, Inc
  9 *
 10 * Contacts: David Cohen <dacohen@gmail.com>
 11 *	     Laurent Pinchart <laurent.pinchart@ideasonboard.com>
 12 *	     Sakari Ailus <sakari.ailus@iki.fi>
 
 
 
 
 13 */
 14
 15#ifndef OMAP3_ISP_STAT_H
 16#define OMAP3_ISP_STAT_H
 17
 18#include <linux/types.h>
 19#include <linux/omap3isp.h>
 20#include <media/v4l2-event.h>
 21
 22#include "isp.h"
 23#include "ispvideo.h"
 24
 25#define STAT_MAX_BUFS		5
 26#define STAT_NEVENTS		8
 27
 28#define STAT_BUF_DONE		0	/* Buffer is ready */
 29#define STAT_NO_BUF		1	/* An error has occurred */
 30#define STAT_BUF_WAITING_DMA	2	/* Histogram only: DMA is running */
 31
 32struct dma_chan;
 33struct ispstat;
 34
 35struct ispstat_buffer {
 36	struct sg_table sgt;
 37	void *virt_addr;
 38	dma_addr_t dma_addr;
 39	struct timespec64 ts;
 40	u32 buf_size;
 41	u32 frame_number;
 42	u16 config_counter;
 43	u8 empty;
 44};
 45
 46struct ispstat_ops {
 47	/*
 48	 * Validate new params configuration.
 49	 * new_conf->buf_size value must be changed to the exact buffer size
 50	 * necessary for the new configuration if it's smaller.
 51	 */
 52	int (*validate_params)(struct ispstat *stat, void *new_conf);
 53
 54	/*
 55	 * Save new params configuration.
 56	 * stat->priv->buf_size value must be set to the exact buffer size for
 57	 * the new configuration.
 58	 * stat->update is set to 1 if new configuration is different than
 59	 * current one.
 60	 */
 61	void (*set_params)(struct ispstat *stat, void *new_conf);
 62
 63	/* Apply stored configuration. */
 64	void (*setup_regs)(struct ispstat *stat, void *priv);
 65
 66	/* Enable/Disable module. */
 67	void (*enable)(struct ispstat *stat, int enable);
 68
 69	/* Verify is module is busy. */
 70	int (*busy)(struct ispstat *stat);
 71
 72	/* Used for specific operations during generic buf process task. */
 73	int (*buf_process)(struct ispstat *stat);
 74};
 75
 76enum ispstat_state_t {
 77	ISPSTAT_DISABLED = 0,
 78	ISPSTAT_DISABLING,
 79	ISPSTAT_ENABLED,
 80	ISPSTAT_ENABLING,
 81	ISPSTAT_SUSPENDED,
 82};
 83
 84struct ispstat {
 85	struct v4l2_subdev subdev;
 86	struct media_pad pad;	/* sink pad */
 87
 88	/* Control */
 89	unsigned configured:1;
 90	unsigned update:1;
 91	unsigned buf_processing:1;
 92	unsigned sbl_ovl_recover:1;
 93	u8 inc_config;
 94	atomic_t buf_err;
 95	enum ispstat_state_t state;	/* enabling/disabling state */
 96	struct isp_device *isp;
 97	void *priv;		/* pointer to priv config struct */
 98	void *recover_priv;	/* pointer to recover priv configuration */
 99	struct mutex ioctl_lock; /* serialize private ioctl */
100
101	const struct ispstat_ops *ops;
102
103	/* Buffer */
104	u8 wait_acc_frames;
105	u16 config_counter;
106	u32 frame_number;
107	u32 buf_size;
108	u32 buf_alloc_size;
109	struct dma_chan *dma_ch;
110	unsigned long event_type;
111	struct ispstat_buffer *buf;
112	struct ispstat_buffer *active_buf;
113	struct ispstat_buffer *locked_buf;
114};
115
116struct ispstat_generic_config {
117	/*
118	 * Fields must be in the same order as in:
119	 *  - omap3isp_h3a_aewb_config
120	 *  - omap3isp_h3a_af_config
121	 *  - omap3isp_hist_config
122	 */
123	u32 buf_size;
124	u16 config_counter;
125};
126
127int omap3isp_stat_config(struct ispstat *stat, void *new_conf);
128int omap3isp_stat_request_statistics(struct ispstat *stat,
129				     struct omap3isp_stat_data *data);
130int omap3isp_stat_request_statistics_time32(struct ispstat *stat,
131				     struct omap3isp_stat_data_time32 *data);
132int omap3isp_stat_init(struct ispstat *stat, const char *name,
133		       const struct v4l2_subdev_ops *sd_ops);
134void omap3isp_stat_cleanup(struct ispstat *stat);
135int omap3isp_stat_subscribe_event(struct v4l2_subdev *subdev,
136				  struct v4l2_fh *fh,
137				  struct v4l2_event_subscription *sub);
138int omap3isp_stat_unsubscribe_event(struct v4l2_subdev *subdev,
139				    struct v4l2_fh *fh,
140				    struct v4l2_event_subscription *sub);
141int omap3isp_stat_s_stream(struct v4l2_subdev *subdev, int enable);
142
143int omap3isp_stat_busy(struct ispstat *stat);
144int omap3isp_stat_pcr_busy(struct ispstat *stat);
145void omap3isp_stat_suspend(struct ispstat *stat);
146void omap3isp_stat_resume(struct ispstat *stat);
147int omap3isp_stat_enable(struct ispstat *stat, u8 enable);
148void omap3isp_stat_sbl_overflow(struct ispstat *stat);
149void omap3isp_stat_isr(struct ispstat *stat);
150void omap3isp_stat_isr_frame_sync(struct ispstat *stat);
151void omap3isp_stat_dma_isr(struct ispstat *stat);
152int omap3isp_stat_register_entities(struct ispstat *stat,
153				    struct v4l2_device *vdev);
154void omap3isp_stat_unregister_entities(struct ispstat *stat);
155
156#endif /* OMAP3_ISP_STAT_H */
v4.17
 
  1/*
  2 * ispstat.h
  3 *
  4 * TI OMAP3 ISP - Statistics core
  5 *
  6 * Copyright (C) 2010 Nokia Corporation
  7 * Copyright (C) 2009 Texas Instruments, Inc
  8 *
  9 * Contacts: David Cohen <dacohen@gmail.com>
 10 *	     Laurent Pinchart <laurent.pinchart@ideasonboard.com>
 11 *	     Sakari Ailus <sakari.ailus@iki.fi>
 12 *
 13 * This program is free software; you can redistribute it and/or modify
 14 * it under the terms of the GNU General Public License version 2 as
 15 * published by the Free Software Foundation.
 16 */
 17
 18#ifndef OMAP3_ISP_STAT_H
 19#define OMAP3_ISP_STAT_H
 20
 21#include <linux/types.h>
 22#include <linux/omap3isp.h>
 23#include <media/v4l2-event.h>
 24
 25#include "isp.h"
 26#include "ispvideo.h"
 27
 28#define STAT_MAX_BUFS		5
 29#define STAT_NEVENTS		8
 30
 31#define STAT_BUF_DONE		0	/* Buffer is ready */
 32#define STAT_NO_BUF		1	/* An error has occurred */
 33#define STAT_BUF_WAITING_DMA	2	/* Histogram only: DMA is running */
 34
 35struct dma_chan;
 36struct ispstat;
 37
 38struct ispstat_buffer {
 39	struct sg_table sgt;
 40	void *virt_addr;
 41	dma_addr_t dma_addr;
 42	struct timeval ts;
 43	u32 buf_size;
 44	u32 frame_number;
 45	u16 config_counter;
 46	u8 empty;
 47};
 48
 49struct ispstat_ops {
 50	/*
 51	 * Validate new params configuration.
 52	 * new_conf->buf_size value must be changed to the exact buffer size
 53	 * necessary for the new configuration if it's smaller.
 54	 */
 55	int (*validate_params)(struct ispstat *stat, void *new_conf);
 56
 57	/*
 58	 * Save new params configuration.
 59	 * stat->priv->buf_size value must be set to the exact buffer size for
 60	 * the new configuration.
 61	 * stat->update is set to 1 if new configuration is different than
 62	 * current one.
 63	 */
 64	void (*set_params)(struct ispstat *stat, void *new_conf);
 65
 66	/* Apply stored configuration. */
 67	void (*setup_regs)(struct ispstat *stat, void *priv);
 68
 69	/* Enable/Disable module. */
 70	void (*enable)(struct ispstat *stat, int enable);
 71
 72	/* Verify is module is busy. */
 73	int (*busy)(struct ispstat *stat);
 74
 75	/* Used for specific operations during generic buf process task. */
 76	int (*buf_process)(struct ispstat *stat);
 77};
 78
 79enum ispstat_state_t {
 80	ISPSTAT_DISABLED = 0,
 81	ISPSTAT_DISABLING,
 82	ISPSTAT_ENABLED,
 83	ISPSTAT_ENABLING,
 84	ISPSTAT_SUSPENDED,
 85};
 86
 87struct ispstat {
 88	struct v4l2_subdev subdev;
 89	struct media_pad pad;	/* sink pad */
 90
 91	/* Control */
 92	unsigned configured:1;
 93	unsigned update:1;
 94	unsigned buf_processing:1;
 95	unsigned sbl_ovl_recover:1;
 96	u8 inc_config;
 97	atomic_t buf_err;
 98	enum ispstat_state_t state;	/* enabling/disabling state */
 99	struct isp_device *isp;
100	void *priv;		/* pointer to priv config struct */
101	void *recover_priv;	/* pointer to recover priv configuration */
102	struct mutex ioctl_lock; /* serialize private ioctl */
103
104	const struct ispstat_ops *ops;
105
106	/* Buffer */
107	u8 wait_acc_frames;
108	u16 config_counter;
109	u32 frame_number;
110	u32 buf_size;
111	u32 buf_alloc_size;
112	struct dma_chan *dma_ch;
113	unsigned long event_type;
114	struct ispstat_buffer *buf;
115	struct ispstat_buffer *active_buf;
116	struct ispstat_buffer *locked_buf;
117};
118
119struct ispstat_generic_config {
120	/*
121	 * Fields must be in the same order as in:
122	 *  - omap3isp_h3a_aewb_config
123	 *  - omap3isp_h3a_af_config
124	 *  - omap3isp_hist_config
125	 */
126	u32 buf_size;
127	u16 config_counter;
128};
129
130int omap3isp_stat_config(struct ispstat *stat, void *new_conf);
131int omap3isp_stat_request_statistics(struct ispstat *stat,
132				     struct omap3isp_stat_data *data);
 
 
133int omap3isp_stat_init(struct ispstat *stat, const char *name,
134		       const struct v4l2_subdev_ops *sd_ops);
135void omap3isp_stat_cleanup(struct ispstat *stat);
136int omap3isp_stat_subscribe_event(struct v4l2_subdev *subdev,
137				  struct v4l2_fh *fh,
138				  struct v4l2_event_subscription *sub);
139int omap3isp_stat_unsubscribe_event(struct v4l2_subdev *subdev,
140				    struct v4l2_fh *fh,
141				    struct v4l2_event_subscription *sub);
142int omap3isp_stat_s_stream(struct v4l2_subdev *subdev, int enable);
143
144int omap3isp_stat_busy(struct ispstat *stat);
145int omap3isp_stat_pcr_busy(struct ispstat *stat);
146void omap3isp_stat_suspend(struct ispstat *stat);
147void omap3isp_stat_resume(struct ispstat *stat);
148int omap3isp_stat_enable(struct ispstat *stat, u8 enable);
149void omap3isp_stat_sbl_overflow(struct ispstat *stat);
150void omap3isp_stat_isr(struct ispstat *stat);
151void omap3isp_stat_isr_frame_sync(struct ispstat *stat);
152void omap3isp_stat_dma_isr(struct ispstat *stat);
153int omap3isp_stat_register_entities(struct ispstat *stat,
154				    struct v4l2_device *vdev);
155void omap3isp_stat_unregister_entities(struct ispstat *stat);
156
157#endif /* OMAP3_ISP_STAT_H */