Linux Audio

Check our new training course

Loading...
v4.6
 
 1/*
 2 * System Trace Module (STM) infrastructure
 3 * Copyright (c) 2014, Intel Corporation.
 4 *
 5 * This program is free software; you can redistribute it and/or modify it
 6 * under the terms and conditions of the GNU General Public License,
 7 * version 2, as published by the Free Software Foundation.
 8 *
 9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12 * more details.
13 *
14 * STM class implements generic infrastructure for  System Trace Module devices
15 * as defined in MIPI STPv2 specification.
16 */
17
18#ifndef _STM_STM_H_
19#define _STM_STM_H_
20
 
 
21struct stp_policy;
22struct stp_policy_node;
 
23
24struct stp_policy_node *
25stp_policy_node_lookup(struct stm_device *stm, char *s);
26void stp_policy_node_put(struct stp_policy_node *policy_node);
27void stp_policy_unbind(struct stp_policy *policy);
28
29void stp_policy_node_get_ranges(struct stp_policy_node *policy_node,
30				unsigned int *mstart, unsigned int *mend,
31				unsigned int *cstart, unsigned int *cend);
32int stp_configfs_init(void);
33void stp_configfs_exit(void);
34
 
 
35struct stp_master {
36	unsigned int	nr_free;
37	unsigned long	chan_map[0];
38};
39
40struct stm_device {
41	struct device		dev;
42	struct module		*owner;
43	struct stp_policy	*policy;
44	struct mutex		policy_mutex;
45	int			major;
46	unsigned int		sw_nmasters;
47	struct stm_data		*data;
48	struct mutex		link_mutex;
49	spinlock_t		link_lock;
50	struct list_head	link_list;
 
 
 
51	/* master allocation */
52	spinlock_t		mc_lock;
53	struct stp_master	*masters[0];
54};
55
56#define to_stm_device(_d)				\
57	container_of((_d), struct stm_device, dev)
58
 
 
 
 
 
 
 
 
 
 
 
 
59struct stm_output {
60	spinlock_t		lock;
61	unsigned int		master;
62	unsigned int		channel;
63	unsigned int		nr_chans;
 
64};
65
66struct stm_file {
67	struct stm_device	*stm;
68	struct stp_policy_node	*policy_node;
69	struct stm_output	output;
70};
71
72struct stm_device *stm_find_device(const char *name);
73void stm_put_device(struct stm_device *stm);
74
75struct stm_source_device {
76	struct device		dev;
77	struct stm_source_data	*data;
78	spinlock_t		link_lock;
79	struct stm_device __rcu	*link;
80	struct list_head	link_entry;
81	/* one output per stm_source device */
82	struct stp_policy_node	*policy_node;
83	struct stm_output	output;
84};
85
86#define to_stm_source_device(_d)				\
87	container_of((_d), struct stm_source_device, dev)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
89#endif /* _STM_STM_H_ */
v6.8
  1/* SPDX-License-Identifier: GPL-2.0 */
  2/*
  3 * System Trace Module (STM) infrastructure
  4 * Copyright (c) 2014, Intel Corporation.
  5 *
 
 
 
 
 
 
 
 
 
  6 * STM class implements generic infrastructure for  System Trace Module devices
  7 * as defined in MIPI STPv2 specification.
  8 */
  9
 10#ifndef _STM_STM_H_
 11#define _STM_STM_H_
 12
 13#include <linux/configfs.h>
 14
 15struct stp_policy;
 16struct stp_policy_node;
 17struct stm_protocol_driver;
 18
 
 
 
 
 
 
 
 
 19int stp_configfs_init(void);
 20void stp_configfs_exit(void);
 21
 22void *stp_policy_node_priv(struct stp_policy_node *pn);
 23
 24struct stp_master {
 25	unsigned int	nr_free;
 26	unsigned long	chan_map[];
 27};
 28
 29struct stm_device {
 30	struct device		dev;
 31	struct module		*owner;
 32	struct stp_policy	*policy;
 33	struct mutex		policy_mutex;
 34	int			major;
 35	unsigned int		sw_nmasters;
 36	struct stm_data		*data;
 37	struct mutex		link_mutex;
 38	spinlock_t		link_lock;
 39	struct list_head	link_list;
 40	/* framing protocol in use */
 41	const struct stm_protocol_driver	*pdrv;
 42	const struct config_item_type		*pdrv_node_type;
 43	/* master allocation */
 44	spinlock_t		mc_lock;
 45	struct stp_master	*masters[];
 46};
 47
 48#define to_stm_device(_d)				\
 49	container_of((_d), struct stm_device, dev)
 50
 51struct stp_policy_node *
 52stp_policy_node_lookup(struct stm_device *stm, char *s);
 53void stp_policy_node_put(struct stp_policy_node *policy_node);
 54void stp_policy_unbind(struct stp_policy *policy);
 55
 56void stp_policy_node_get_ranges(struct stp_policy_node *policy_node,
 57				unsigned int *mstart, unsigned int *mend,
 58				unsigned int *cstart, unsigned int *cend);
 59
 60const struct config_item_type *
 61get_policy_node_type(struct configfs_attribute **attrs);
 62
 63struct stm_output {
 64	spinlock_t		lock;
 65	unsigned int		master;
 66	unsigned int		channel;
 67	unsigned int		nr_chans;
 68	void			*pdrv_private;
 69};
 70
 71struct stm_file {
 72	struct stm_device	*stm;
 
 73	struct stm_output	output;
 74};
 75
 76struct stm_device *stm_find_device(const char *name);
 77void stm_put_device(struct stm_device *stm);
 78
 79struct stm_source_device {
 80	struct device		dev;
 81	struct stm_source_data	*data;
 82	spinlock_t		link_lock;
 83	struct stm_device __rcu	*link;
 84	struct list_head	link_entry;
 85	/* one output per stm_source device */
 
 86	struct stm_output	output;
 87};
 88
 89#define to_stm_source_device(_d)				\
 90	container_of((_d), struct stm_source_device, dev)
 91
 92void *to_pdrv_policy_node(struct config_item *item);
 93
 94struct stm_protocol_driver {
 95	struct module	*owner;
 96	const char	*name;
 97	ssize_t		(*write)(struct stm_data *data,
 98				 struct stm_output *output, unsigned int chan,
 99				 const char *buf, size_t count);
100	void		(*policy_node_init)(void *arg);
101	int		(*output_open)(void *priv, struct stm_output *output);
102	void		(*output_close)(struct stm_output *output);
103	ssize_t		priv_sz;
104	struct configfs_attribute	**policy_attr;
105};
106
107int stm_register_protocol(const struct stm_protocol_driver *pdrv);
108void stm_unregister_protocol(const struct stm_protocol_driver *pdrv);
109int stm_lookup_protocol(const char *name,
110			const struct stm_protocol_driver **pdrv,
111			const struct config_item_type **type);
112void stm_put_protocol(const struct stm_protocol_driver *pdrv);
113ssize_t stm_data_write(struct stm_data *data, unsigned int m,
114		       unsigned int c, bool ts_first, const void *buf,
115		       size_t count);
116
117#endif /* _STM_STM_H_ */