Debian Codegraph @

include/dahdi/kernel.h

raw symbols ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 /*
2 * DAHDI Telephony Interface
3 *
4 * Written by Mark Spencer <[email protected]>
5 * Based on previous works, designs, and architectures conceived and
6 * written by Jim Dixon <[email protected]>.
7 *
8 * Copyright (C) 2001 Jim Dixon / Zapata Telephony.
9 * Copyright (C) 2001 - 2012 Digium, Inc.
10 *
11 * All rights reserved.
12 *
13 */
14
15 /*
16 * See http://www.asterisk.org for more information about
17 * the Asterisk project. Please do not directly contact
18 * any of the maintainers of this project for assistance;
19 * the project provides a web site, mailing lists and IRC
20 * channels for your use.
21 *
22 * This program is free software, distributed under the terms of
23 * the GNU General Public License Version 2 as published by the
24 * Free Software Foundation. See the LICENSE file included with
25 * this program for more details.
26 */
27
28 /*!
29 * \file
30 * \brief DAHDI kernel interface definitions
31 */
32
33 #ifndef _DAHDI_KERNEL_H
34 #define _DAHDI_KERNEL_H
35
36 #include <dahdi/user.h>
37 #include <dahdi/fasthdlc.h>
38
39 #include <dahdi/dahdi_config.h>
40 #include <linux/version.h>
41 #include <linux/fs.h>
42 #include <linux/device.h>
43 #include <linux/cdev.h>
44 #include <linux/module.h>
45 #include <linux/ioctl.h>
46
47 #ifdef CONFIG_DAHDI_NET
48 #include <linux/hdlc.h>
49 #endif
50
51 #ifdef CONFIG_DAHDI_PPP
52 #include <linux/ppp_channel.h>
53 #include <linux/skbuff.h>
54 #include <linux/interrupt.h>
55 #endif
56 #include <linux/device.h>
57 #include <linux/sysfs.h>
58
59 #include <linux/poll.h>
60
61 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
62 #include <linux/compiler_attributes.h>
63 #endif
64 #ifndef fallthrough
65 #define fallthrough do {} while (0) /* fallthrough */
66 #endif
67
68 #ifdef CONFIG_PCI
69 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)
70 #include <linux/pci.h>
71 #else
72 #include <linux/pci-aspm.h>
73 #endif
74 #endif
75
76 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)
77 #define PDE_DATA(i) pde_data(i)
78 #endif
79
80 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
81 #include <linux/dma-mapping.h>
82 static inline void *
83 pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
84 dma_addr_t *dma_handle)
85 {
86 return dma_alloc_coherent(&hwdev->dev, size, dma_handle, GFP_ATOMIC);
87 }
88
89 static inline void
90 pci_free_consistent(struct pci_dev *hwdev, size_t size,
91 void *vaddr, dma_addr_t dma_handle)
92 {
93 dma_free_coherent(&hwdev->dev, size, vaddr, dma_handle);
94 }
95 static inline dma_addr_t
96 pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction)
97 {
98 return dma_map_single(&hwdev->dev, ptr, size, (enum dma_data_direction)direction);
99 }
100
101 static inline void
102 pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr,
103 size_t size, int direction)
104 {
105 dma_unmap_single(&hwdev->dev, dma_addr, size, (enum dma_data_direction)direction);
106 }
107 static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask)
108 {
109 return dma_set_mask(&dev->dev, mask);
110 }
111 #endif
112
113 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
114 #define HAVE_NET_DEVICE_OPS
115 #endif
116
117 /* __dev* were removed in 3.8. They still have effect in 2.6.18. */
118 #ifndef __devinit
119 # define __devinit
120 # define __devinitdata
121 # define __devexit
122 # define __devexit_p(x) x
123 #endif
124
125 /*! Default chunk size for conferences and such -- static right now, might make
126 variable sometime. 8 samples = 1 ms = most frequent service interval possible
127 for a USB device */
128 #define DAHDI_CHUNKSIZE 8
129 #define DAHDI_MIN_CHUNKSIZE DAHDI_CHUNKSIZE
130 #define DAHDI_DEFAULT_CHUNKSIZE DAHDI_CHUNKSIZE
131 #define DAHDI_MAX_CHUNKSIZE DAHDI_CHUNKSIZE
132 #define DAHDI_CB_SIZE (1 << 3)
133
134 /* DAHDI operates at 8Khz by default */
135 #define DAHDI_MS_TO_SAMPLES(ms) ((ms) * 8)
136
137 #define DAHDI_MSECS_PER_CHUNK (DAHDI_CHUNKSIZE/DAHDI_MS_TO_SAMPLES(1))
138
139 #define RING_DEBOUNCE_TIME 2000 /*!< 2000 ms ring debounce time */
140
141 typedef struct
142 {
143 int32_t gain;
144 int32_t a1;
145 int32_t a2;
146 int32_t b1;
147 int32_t b2;
148
149 int32_t z1;
150 int32_t z2;
151 } biquad2_state_t;
152
153 typedef struct
154 {
155 biquad2_state_t notch;
156 int notch_level;
157 int channel_level;
158 int tone_present;
159 int tone_cycle_duration;
160 int good_cycles;
161 int hit;
162 } echo_can_disable_detector_state_t;
163
164 struct sf_detect_state {
165 long x1;
166 long x2;
167 long y1;
168 long y2;
169 long e1;
170 long e2;
171 int samps;
172 int lastdetect;
173 };
174
175 struct dahdi_tone_state {
176 int v1_1;
177 int v2_1;
178 int v3_1;
179 int v1_2;
180 int v2_2;
181 int v3_2;
182 int modulate;
183 };
184
185 /*! \brief Conference queue structure */
186 struct confq {
187 u_char buffer[DAHDI_CHUNKSIZE * DAHDI_CB_SIZE];
188 u_char *buf[DAHDI_CB_SIZE];
189 int inbuf;
190 int outbuf;
191 };
192
193 struct dahdi_chan;
194 struct dahdi_echocan_state;
195
196 /*! Features a DAHDI echo canceler (software or hardware) can provide to the DAHDI core. */
197 struct dahdi_echocan_features {
198
199 /*! Able to detect CED tone (2100 Hz with phase reversals) in the transmit direction.
200 * If the echocan can detect this tone, it may report it it as an event (see
201 * the events.CED_tx_detected field of dahdi_echocan_state), and if it will automatically
202 * disable itself or its non-linear processor, then the NLP_automatic feature flag should also
203 * be set so that the DAHDI core doesn't bother trying to do so.
204 */
205 u32 CED_tx_detect:1;
206
207 /*! Able to detect CED tone (2100 Hz with phase reversals) in the receive direction.
208 * If the echocan can detect this tone, it may report it it as an event (see
209 * the events.CED_rx_detected field of dahdi_echocan_state), and if it will automatically
210 * disable itself or its non-linear processor, then the NLP_automatic flag feature should also
211 * be set so that the DAHDI core doesn't bother trying to do so.
212 */
213 u32 CED_rx_detect:1;
214
215 /*! Able to detect CNG tone (1100 Hz) in the transmit direction. */
216 u32 CNG_tx_detect:1;
217
218 /*! Able to detect CNG tone (1100 Hz) in the receive direction. */
219 u32 CNG_rx_detect:1;
220
221 /*! If the echocan's NLP can be enabled and disabled without requiring destruction
222 * and recreation of the state structure, this feature flag should be set and the
223 * echocan_NLP_toggle field of the dahdi_echocan_ops structure should be filled with a
224 * pointer to the function to perform that operation.
225 */
226 u32 NLP_toggle:1;
227
228 /*! If the echocan will automatically disable itself (or even just its NLP) based on
229 * detection of a CED tone in either direction, this feature flag should be set (along
230 * with the tone detection feature flags).
231 */
232 u32 NLP_automatic:1;
233 };
234
235 /*! Operations (methods) that can be performed on a DAHDI echo canceler instance (state
236 * structure) after it has been created, by either a software or hardware echo canceller.
237 * The echo canceler must populate the owner field of the dahdi_echocan_state structure
238 * with a pointer to the relevant operations structure for that instance.
239 */
240 struct dahdi_echocan_ops {
241
242 /*! \brief Free an echocan state structure.
243 * \param[in,out] ec Pointer to the state structure to free.
244 *
245 * \return Nothing.
246 */
247 void (*echocan_free)(struct dahdi_chan *chan, struct dahdi_echocan_state *ec);
248
249 /*! \brief Process an array of audio samples through the echocan.
250 * \param[in,out] ec Pointer to the state structure.
251 * \param[in,out] isig The receive direction data (will be modified).
252 * \param[in] iref The transmit direction data.
253 * \param[in] size The number of elements in the isig and iref arrays.
254 *
255 * Note: This function can also return events in the events field of the
256 * dahdi_echocan_state structure. If it can do so, then the echocan does
257 * not need to provide the echocan_events function.
258 *
259 * \return Nothing.
260 */
261 void (*echocan_process)(struct dahdi_echocan_state *ec, short *isig, const short *iref, u32 size);
262
263 /*! \brief Retrieve events from the echocan.
264 * \param[in,out] ec Pointer to the state structure.
265 *
266 *
267 * If any events have occurred, the events field of the dahdi_echocan_state
268 * structure should be updated to include them.
269 *
270 * \return Nothing.
271 */
272 void (*echocan_events)(struct dahdi_echocan_state *ec);
273
274 /*! \brief Feed a sample (and its position) for echocan training.
275 * \param[in,out] ec Pointer to the state structure.
276 * \param[in] pos The tap position to be 'trained'.
277 * \param[in] val The receive direction sample for the specified tap position.
278 *
279 * \retval Zero if training should continue.
280 * \retval Non-zero if training is complete.
281 */
282 int (*echocan_traintap)(struct dahdi_echocan_state *ec, int pos, short val);
283
284 /*! \brief Enable or disable non-linear processing (NLP) in the echocan.
285 * \param[in,out] ec Pointer to the state structure.
286 * \param[in] enable Zero to disable, non-zero to enable.
287 *
288 * \return Nothing.
289 */
290 void (*echocan_NLP_toggle)(struct dahdi_echocan_state *ec, unsigned int enable);
291
292 #ifdef CONFIG_DAHDI_ECHOCAN_PROCESS_TX
293 /*! \brief Process an array of TX audio samples.
294 *
295 * \return Nothing.
296 */
297 void (*echocan_process_tx)(struct dahdi_echocan_state *ec,
298 short *tx, u32 size);
299 #endif
300 };
301
302 /*! A factory for creating instances of software echo cancelers to be used on DAHDI channels. */
303 struct dahdi_echocan_factory {
304
305 /*! Get the name of the factory. */
306 const char *(*get_name)(const struct dahdi_chan *chan);
307
308 /*! Pointer to the module that owns this factory; the module's reference count will be
309 * incremented/decremented by the DAHDI core as needed.
310 */
311 struct module *owner;
312
313 /*! \brief Function to create an instance of the echocan.
314 * \param[in] ecp Structure defining parameters to be used for the instance creation.
315 * \param[in] p Pointer to the beginning of an (optional) array of user-defined parameters.
316 * \param[out] ec Pointer to the state structure that is created, if any.
317 *
318 * \retval Zero on success.
319 * \retval Non-zero on failure (return value will be returned to userspace so it should be a
320 * standard error number).
321 */
322 int (*echocan_create)(struct dahdi_chan *chan, struct dahdi_echocanparams *ecp,
323 struct dahdi_echocanparam *p, struct dahdi_echocan_state **ec);
324 };
325
326 /*! \brief Register an echo canceler factory with the DAHDI core.
327 * \param[in] ec Pointer to the dahdi_echocan_factory structure to be registered.
328 *
329 * \retval Zero on success.
330 * \retval Non-zero on failure (return value will be a standard error number).
331 */
332 int dahdi_register_echocan_factory(const struct dahdi_echocan_factory *ec);
333
334 /*! \brief Unregister a previously-registered echo canceler factory from the DAHDI core.
335 * \param[in] ec Pointer to the dahdi_echocan_factory structure to be unregistered.
336 *
337 * \return Nothing.
338 */
339 void dahdi_unregister_echocan_factory(const struct dahdi_echocan_factory *ec);
340
341 enum dahdi_echocan_mode {
342 __ECHO_MODE_MUTE = 1 << 8,
343 ECHO_MODE_IDLE = 0,
344 ECHO_MODE_PRETRAINING = 1 | __ECHO_MODE_MUTE,
345 ECHO_MODE_STARTTRAINING = 2 | __ECHO_MODE_MUTE,
346 ECHO_MODE_AWAITINGECHO = 3 | __ECHO_MODE_MUTE,
347 ECHO_MODE_TRAINING = 4 | __ECHO_MODE_MUTE,
348 ECHO_MODE_ACTIVE = 5,
349 ECHO_MODE_FAX = 6,
350 };
351
352 /*! An instance of a DAHDI echo canceler (software or hardware). */
353 struct dahdi_echocan_state {
354
355 /*! Pointer to a dahdi_echocan_ops structure of operations that can be
356 * performed on this instance.
357 */
358 const struct dahdi_echocan_ops *ops;
359
360 /*! State data used by the DAHDI core's CED detector for the transmit
361 * direction, if needed.
362 */
363 echo_can_disable_detector_state_t txecdis;
364
365 /*! State data used by the DAHDI core's CED detector for the receive
366 * direction, if needed.
367 */
368 echo_can_disable_detector_state_t rxecdis;
369
370 /*! Features offered by the echo canceler that provided this instance. */
371 struct dahdi_echocan_features features;
372
373 struct {
374 /*! The mode the echocan is currently in. */
375 enum dahdi_echocan_mode mode;
376
377 /*! The last tap position that was fed to the echocan's training function. */
378 u32 last_train_tap;
379
380 /*! How many samples to wait before beginning the training operation. */
381 u32 pretrain_timer;
382 } status;
383
384 /*! This structure contains event flags, allowing the echocan to report
385 * events that occurred as it processed the transmit and receive streams
386 * of samples. Each call to the echocan_process operation for this
387 * instance may report events, so the structure should be cleared before
388 * calling that operation.
389 */
390 union dahdi_echocan_events {
391 u32 all;
392 struct {
393 /*! CED tone was detected in the transmit direction. If the
394 * echocan automatically disables its NLP when this occurs,
395 * it must also signal the NLP_auto_disabled event during the *same*
396 * call to echocan_process that reports the CED detection.
397 */
398 u32 CED_tx_detected:1;
399
400 /*! CED tone was detected in the receive direction. If the
401 * echocan automatically disables its NLP when this occurs,
402 * it must also signal the NLP_auto_disabled event during the *same*
403 * call to echocan_process that reports the CED detection.
404 */
405 u32 CED_rx_detected:1;
406
407 /*! CNG tone was detected in the transmit direction. */
408 u32 CNG_tx_detected:1;
409
410 /*! CNG tone was detected in the receive direction. */
411 u32 CNG_rx_detected:1;
412
413 /*! The echocan disabled its NLP automatically.
414 */
415 u32 NLP_auto_disabled:1;
416
417 /*! The echocan enabled its NLP automatically.
418 */
419 u32 NLP_auto_enabled:1;
420 } bit;
421 } events;
422 };
423
424 struct dahdi_chan {
425 #ifdef CONFIG_DAHDI_NET
426 /*! \note Must be first */
427 struct dahdi_hdlc *hdlcnetdev;
428 #endif
429 #ifdef CONFIG_DAHDI_PPP
430 struct ppp_channel *ppp;
431 struct tasklet_struct ppp_calls;
432 int do_ppp_wakeup;
433 int do_ppp_error;
434 struct sk_buff_head ppp_rq;
435 #endif
436 #ifdef BUFFER_DEBUG
437 int statcount;
438 int lastnumbufs;
439 #endif
440 spinlock_t lock;
441 struct mutex mutex;
442 char name[40];
443 /* Specified by DAHDI */
444 /*! \brief DAHDI channel number */
445 int channo;
446 int chanpos;
447 unsigned long flags;
448 long rxp1;
449 long rxp2;
450 long rxp3;
451 int txtone;
452 int tx_v2;
453 int tx_v3;
454 int v1_1;
455 int v2_1;
456 int v3_1;
457 int toneflags;
458 struct sf_detect_state rd;
459
460 struct dahdi_chan *master; /*!< Our Master channel (could be us) */
461 /*! \brief Next slave (if appropriate) */
462 struct dahdi_chan *nextslave;
463
464 u_char *writechunk; /*!< Actual place to write to */
465 u_char swritechunk[DAHDI_MAX_CHUNKSIZE]; /*!< Buffer to be written */
466 u_char *readchunk; /*!< Actual place to read from */
467 u_char sreadchunk[DAHDI_MAX_CHUNKSIZE]; /*!< Preallocated static area */
468 short *readchunkpreec;
469
470 /* Channel from which to read when DACSed. */
471 struct dahdi_chan *dacs_chan;
472
473 /*! Pointer to tx and rx gain tables */
474 const u_char *rxgain;
475 const u_char *txgain;
476
477 /* Specified by driver, readable by DAHDI */
478 void *pvt; /*!< Private channel data */
479 struct file *file; /*!< File structure */
480
481
482 #ifdef CONFIG_DAHDI_MIRROR
483 struct dahdi_chan *rxmirror; /*!< channel we mirror reads to */
484 struct dahdi_chan *txmirror; /*!< channel we mirror writes to */
485 struct dahdi_chan *srcmirror; /*!< channel we mirror from */
486 #endif /* CONFIG_DAHDI_MIRROR */
487 struct dahdi_span *span; /*!< Span we're a member of */
488 int sig; /*!< Signalling */
489 int sigcap; /*!< Capability for signalling */
490 __u32 chan_alarms; /*!< alarms status */
491
492 wait_queue_head_t waitq;
493
494 /* Used only by DAHDI -- NO DRIVER SERVICEABLE PARTS BELOW */
495 /* Buffer declarations */
496 u_char *readbuf[DAHDI_MAX_NUM_BUFS]; /*!< read buffer */
497 int inreadbuf;
498 int outreadbuf;
499
500 u_char *writebuf[DAHDI_MAX_NUM_BUFS]; /*!< write buffers */
501 int inwritebuf;
502 int outwritebuf;
503
504 int blocksize; /*!< Block size */
505
506 int eventinidx; /*!< out index in event buf (circular) */
507 int eventoutidx; /*!< in index in event buf (circular) */
508 unsigned int eventbuf[DAHDI_MAX_EVENTSIZE]; /*!< event circ. buffer */
509
510 int readn[DAHDI_MAX_NUM_BUFS]; /*!< # of bytes ready in read buf */
511 int readidx[DAHDI_MAX_NUM_BUFS]; /*!< current read pointer */
512 int writen[DAHDI_MAX_NUM_BUFS]; /*!< # of bytes ready in write buf */
513 int writeidx[DAHDI_MAX_NUM_BUFS]; /*!< current write pointer */
514
515 int numbufs; /*!< How many buffers in channel */
516 int txbufpolicy; /*!< Buffer policy */
517 int txdisable; /*!< Disable transmitter */
518
519 /* Tone zone stuff */
520 struct dahdi_zone *curzone; /*!< Zone for selecting tones */
521 struct dahdi_tone *curtone; /*!< Current tone we're playing (if any) */
522 int tonep; /*!< Current position in tone */
523 struct dahdi_tone_state ts; /*!< Tone state */
524
525 /* Pulse dial stuff */
526 int pdialcount; /*!< pulse dial count */
527
528 /*! Ring cadence */
529 int ringcadence[DAHDI_MAX_CADENCE];
530 int firstcadencepos; /*!< Where to restart ring cadence */
531
532 /* Digit string dialing stuff */
533 int digitmode; /*!< What kind of tones are we sending? */
534 char txdialbuf[DAHDI_MAX_DTMF_BUF];
535 int dialing;
536 int afterdialingtimer;
537 int cadencepos; /*!< Where in the cadence we are */
538
539 /* I/O Mask */
540 unsigned int iomask; /*! I/O Mux signal mask */
541
542 /* HDLC state machines */
543 struct fasthdlc_state txhdlc;
544 struct fasthdlc_state rxhdlc;
545 int infcs;
546
547 /* Conferencing stuff */
548 int confna; /*! conference number (alias) */
549 int _confn; /*! Actual conference number */
550 int confmode; /*! conference mode */
551 int confmute; /*! conference mute mode */
552 struct dahdi_chan *conf_chan;
553
554 /* Incoming and outgoing conference chunk queues for
555 communicating between DAHDI master time and
556 other boards */
557 struct confq confin;
558 struct confq confout;
559
560 short getlin[DAHDI_MAX_CHUNKSIZE]; /*!< Last transmitted samples */
561 unsigned char getraw[DAHDI_MAX_CHUNKSIZE]; /*!< Last received raw data */
562 short putlin[DAHDI_MAX_CHUNKSIZE]; /*!< Last received samples */
563 unsigned char putraw[DAHDI_MAX_CHUNKSIZE]; /*!< Last received raw data */
564 short conflast[DAHDI_MAX_CHUNKSIZE]; /*!< Last conference sample -- base part of channel */
565 short conflast1[DAHDI_MAX_CHUNKSIZE]; /*!< Last conference sample -- pseudo part of channel */
566 short conflast2[DAHDI_MAX_CHUNKSIZE]; /*!< Previous last conference sample -- pseudo part of channel */
567
568
569 /*! The echo canceler module that should be used to create an
570 instance when this channel needs one */
571 const struct dahdi_echocan_factory *ec_factory;
572 /*! The echo canceler module that owns the instance currently
573 on this channel, if one is present */
574 const struct dahdi_echocan_factory *ec_current;
575 /*! The state data of the echo canceler instance in use */
576 struct dahdi_echocan_state *ec_state;
577
578 /* RBS timings */
579 int prewinktime; /*!< pre-wink time (ms) */
580 int preflashtime; /*!< pre-flash time (ms) */
581 int winktime; /*!< wink time (ms) */
582 int flashtime; /*!< flash time (ms) */
583 int starttime; /*!< start time (ms) */
584 int rxwinktime; /*!< rx wink time (ms) */
585 int rxflashtime; /*!< rx flash time (ms) */
586 int debouncetime; /*!< FXS GS sig debounce time (ms) */
587 int pulsebreaktime; /*!< pulse line open time (ms) */
588 int pulsemaketime; /*!< pulse line closed time (ms) */
589 int pulseaftertime; /*!< pulse time between digits (ms) */
590
591 /*! RING debounce timer */
592 int ringdebtimer;
593
594 /*! RING trailing detector to make sure a RING is really over */
595 int ringtrailer;
596
597 /* PULSE digit receiver stuff */
598 int pulsecount;
599 int pulsetimer;
600
601 /* RBS timers */
602 int itimerset; /*!< what the itimer was set to last */
603 int itimer;
604 int otimer;
605
606 /* RBS state */
607 int gotgs;
608 int txstate;
609 int rxsig;
610 int txsig;
611 int rxsigstate;
612
613 /* non-RBS rx state */
614 int rxhooksig;
615 int txhooksig;
616 int kewlonhook;
617
618 /*! Idle signalling if CAS signalling */
619 int idlebits;
620
621 int deflaw; /*! 1 = mulaw, 2=alaw, 0=undefined */
622 short *xlaw;
623 #ifdef OPTIMIZE_CHANMUTE
624 int chanmute; /*!< no need for PCM data */
625 #endif
626 #ifdef CONFIG_CALC_XLAW
627 unsigned char (*lineartoxlaw)(short a);
628 #else
629 unsigned char *lin2x;
630 #endif
631 struct device chan_device; /*!< Kernel object for this chan */
632 #define dev_to_chan(dev) container_of(dev, struct dahdi_chan, chan_device)
633 };
634
635 #ifdef CONFIG_DAHDI_NET
636 struct dahdi_hdlc {
637 struct net_device *netdev;
638 struct dahdi_chan *chan;
639 };
640 #endif
641
642 /*! Define the maximum block size */
643 #define DAHDI_MAX_BLOCKSIZE 8192
644
645
646 #define DAHDI_DEFAULT_WINKTIME 150 /*!< 150 ms default wink time */
647 #define DAHDI_DEFAULT_FLASHTIME 750 /*!< 750 ms default flash time */
648
649 #define DAHDI_DEFAULT_PREWINKTIME 50 /*!< 50 ms before wink */
650 #define DAHDI_DEFAULT_PREFLASHTIME 50 /*!< 50 ms before flash */
651 #define DAHDI_DEFAULT_STARTTIME 1500 /*!< 1500 ms of start */
652 #define DAHDI_DEFAULT_RINGTIME 2000 /*!< 2000 ms of ring on (start, FXO) */
653 #if 0
654 #define DAHDI_DEFAULT_RXWINKTIME 250 /*!< 250ms longest rx wink */
655 #endif
656 #define DAHDI_DEFAULT_RXWINKTIME 300 /*!< 300ms longest rx wink (to work with the Atlas) */
657 #define DAHDI_DEFAULT_RXFLASHTIME 1250 /*!< 1250ms longest rx flash */
658 #define DAHDI_DEFAULT_DEBOUNCETIME 600 /*!< 600ms of FXS GS signalling debounce */
659 #define DAHDI_DEFAULT_PULSEMAKETIME 50 /*!< 50 ms of line closed when dial pulsing */
660 #define DAHDI_DEFAULT_PULSEBREAKTIME 50 /*!< 50 ms of line open when dial pulsing */
661 #define DAHDI_DEFAULT_PULSEAFTERTIME 750 /*!< 750ms between dial pulse digits */
662
663 #define DAHDI_MINPULSETIME (15 * 8) /*!< 15 ms minimum */
664
665 #ifdef SHORT_FLASH_TIME
666 #define DAHDI_MAXPULSETIME (80 * 8) /*!< we need 80 ms, not 200ms, as we have a short flash */
667 #else
668 #define DAHDI_MAXPULSETIME (200 * 8) /*!< 200 ms maximum */
669 #endif
670
671 #define DAHDI_PULSETIMEOUT ((DAHDI_MAXPULSETIME / 8) + 50)
672
673 #define DAHDI_RINGTRAILER (50 * 8) /*!< Don't consider a ring "over" until it's been gone at least this
674 much time */
675
676 #define DAHDI_LOOPCODE_TIME 10000 /*!< send loop codes for 10 secs */
677 #define DAHDI_ALARMSETTLE_TIME 5000 /*!< allow alarms to settle for 5 secs */
678 #define DAHDI_AFTERSTART_TIME 500 /*!< 500ms after start */
679
680 #define DAHDI_RINGOFFTIME 4000 /*!< Turn off ringer for 4000 ms */
681 #define DAHDI_KEWLTIME 500 /*!< 500ms for kewl pulse */
682 #define DAHDI_AFTERKEWLTIME 300 /*!< 300ms after kewl pulse */
683
684 #define DAHDI_MAX_PRETRAINING 1000 /*!< 1000ms max pretraining time */
685
686 #ifdef FXSFLASH
687 #define DAHDI_FXSFLASHMINTIME 450 /*!< min 450ms */
688 #define DAHDI_FXSFLASHMAXTIME 550 /*!< max 550ms */
689 #endif
690
691
692 struct dahdi_chardev {
693 const char *name;
694 __u8 minor;
695 };
696
697 int dahdi_register_chardev(struct dahdi_chardev *dev);
698 int dahdi_unregister_chardev(struct dahdi_chardev *dev);
699
700 /*! \brief defines for transmit signalling */
701 enum dahdi_txsig {
702 DAHDI_TXSIG_ONHOOK, /*!< On hook */
703 DAHDI_TXSIG_OFFHOOK, /*!< Off hook */
704 DAHDI_TXSIG_START, /*!< Start / Ring */
705 DAHDI_TXSIG_KEWL, /*!< Drop battery if possible */
706 /*! Leave this as the last entry */
707 DAHDI_TXSIG_TOTAL,
708 };
709
710 enum dahdi_rxsig {
711 DAHDI_RXSIG_ONHOOK,
712 DAHDI_RXSIG_OFFHOOK,
713 DAHDI_RXSIG_START,
714 DAHDI_RXSIG_RING,
715 DAHDI_RXSIG_INITIAL
716 };
717
718 enum {
719 /* Span flags */
720 DAHDI_FLAGBIT_REGISTERED= 0,
721 DAHDI_FLAGBIT_RUNNING = 1,
722 DAHDI_FLAGBIT_RBS = 12, /*!< Span uses RBS signalling */
723
724 /* Channel flags */
725 DAHDI_FLAGBIT_DTMFDECODE= 2, /*!< Channel supports native DTMF decode */
726 DAHDI_FLAGBIT_MFDECODE = 3, /*!< Channel supports native MFr2 decode */
727 DAHDI_FLAGBIT_ECHOCANCEL= 4, /*!< Channel supports native echo cancellation */
728 DAHDI_FLAGBIT_HDLC = 5, /*!< Perform HDLC */
729 #ifdef CONFIG_DAHDI_NET
730 DAHDI_FLAGBIT_NETDEV = 6, /*!< Send to network */
731 #endif
732 DAHDI_FLAGBIT_CLEAR = 8, /*!< Clear channel */
733 DAHDI_FLAGBIT_AUDIO = 9, /*!< Audio mode channel */
734 DAHDI_FLAGBIT_OPEN = 10, /*!< Channel is open */
735 DAHDI_FLAGBIT_FCS = 11, /*!< Calculate FCS */
736 /* Reserve 12 for uniqueness with span flags */
737 DAHDI_FLAGBIT_LINEAR = 13, /*!< Talk to user space in linear */
738 DAHDI_FLAGBIT_PPP = 14, /*!< PPP is available */
739 DAHDI_FLAGBIT_T1PPP = 15,
740 DAHDI_FLAGBIT_SIGFREEZE = 16, /*!< Freeze signalling */
741 DAHDI_FLAGBIT_NOSTDTXRX = 17, /*!< Do NOT do standard transmit and receive on every interrupt */
742 DAHDI_FLAGBIT_LOOPED = 18, /*!< Loopback the receive data from the channel to the transmit */
743 DAHDI_FLAGBIT_MTP2 = 19, /*!< Repeats last message in buffer and also discards repeating messages sent to us */
744 DAHDI_FLAGBIT_HDLC56 = 20, /*!< Sets the given channel (if in HDLC mode) to use 56K HDLC instead of 64K */
745 DAHDI_FLAGBIT_BUFEVENTS = 21, /*!< Report buffer events */
746 DAHDI_FLAGBIT_TXUNDERRUN = 22, /*!< Transmit underrun condition */
747 DAHDI_FLAGBIT_RXOVERRUN = 23, /*!< Receive overrun condition */
748 DAHDI_FLAGBIT_DEVFILE = 25, /*!< Channel has a sysfs dev file */
749 };
750
751 #ifdef CONFIG_DAHDI_NET
752 /**
753 * have_netdev() - Return true if a channel has an associated network device.
754 * @chan: Then channel to check.
755 *
756 */
757 static inline int dahdi_have_netdev(const struct dahdi_chan *chan)
758 {
759 return test_bit(DAHDI_FLAGBIT_NETDEV, &chan->flags);
760 }
761 #else
762 static inline int dahdi_have_netdev(const struct dahdi_chan *chan) { return 0; }
763 #endif
764
765 struct dahdi_count {
766 u32 fe; /*!< Framing error counter */
767 u32 cv; /*!< Coding violations counter */
768 u32 bpv; /*!< Bipolar Violation counter */
769 u32 crc4; /*!< CRC4 error counter */
770 u32 ebit; /*!< current E-bit error count */
771 u32 fas; /*!< current FAS error count */
772 u32 be; /*!< current bit error count */
773 u32 prbs; /*!< current PRBS detected pattern */
774 u32 errsec; /*!< errored seconds */
775 u32 timingslips; /*!< Clock slips */
776 };
777
778 /* map flagbits to flag masks */
779 #define DAHDI_FLAG(x) (1 << (DAHDI_FLAGBIT_ ## x))
780
781 /*! This is a redefinition of the flags from above to allow use of the
782 * legacy drivers that do not use the kernel atomic bit testing and
783 * changing routines.
784 *
785 * See the above descriptions for DAHDI_FLAGBIT_.... for documentation
786 * about function. */
787 /* Span flags */
788 #define DAHDI_FLAG_REGISTERED DAHDI_FLAG(REGISTERED)
789 #define DAHDI_FLAG_RUNNING DAHDI_FLAG(RUNNING)
790 #define DAHDI_FLAG_RBS DAHDI_FLAG(RBS)
791
792 /* Channel flags */
793 #define DAHDI_FLAG_DTMFDECODE DAHDI_FLAG(DTMFDECODE)
794 #define DAHDI_FLAG_MFDECODE DAHDI_FLAG(MFDECODE)
795 #define DAHDI_FLAG_ECHOCANCEL DAHDI_FLAG(ECHOCANCEL)
796
797 #define DAHDI_FLAG_HDLC DAHDI_FLAG(HDLC)
798 /* #define DAHDI_FLAG_NETDEV DAHDI_FLAG(NETDEV) */
799 #define DAHDI_FLAG_CLEAR DAHDI_FLAG(CLEAR)
800 #define DAHDI_FLAG_AUDIO DAHDI_FLAG(AUDIO)
801
802 #define DAHDI_FLAG_OPEN DAHDI_FLAG(OPEN)
803 #define DAHDI_FLAG_FCS DAHDI_FLAG(FCS)
804 /* Reserve 12 for uniqueness with span flags */
805 #define DAHDI_FLAG_LINEAR DAHDI_FLAG(LINEAR)
806 #define DAHDI_FLAG_PPP DAHDI_FLAG(PPP)
807 #define DAHDI_FLAG_T1PPP DAHDI_FLAG(T1PPP)
808 #define DAHDI_FLAG_SIGFREEZE DAHDI_FLAG(SIGFREEZE)
809 #define DAHDI_FLAG_NOSTDTXRX DAHDI_FLAG(NOSTDTXRX)
810 #define DAHDI_FLAG_LOOPED DAHDI_FLAG(LOOPED)
811 #define DAHDI_FLAG_MTP2 DAHDI_FLAG(MTP2)
812 #define DAHDI_FLAG_HDLC56 DAHDI_FLAG(HDLC56)
813 #define DAHDI_FLAG_BUFEVENTS DAHDI_FLAG(BUFEVENTS)
814 #define DAHDI_FLAG_TXUNDERRUN DAHDI_FLAG(TXUNDERRUN)
815 #define DAHDI_FLAG_RXOVERRUN DAHDI_FLAG(RXOVERRUN)
816
817 enum spantypes {
818 SPANTYPE_INVALID = 0,
819 SPANTYPE_ANALOG_FXS,
820 SPANTYPE_ANALOG_FXO,
821 SPANTYPE_ANALOG_MIXED,
822 SPANTYPE_DIGITAL_E1,
823 SPANTYPE_DIGITAL_T1,
824 SPANTYPE_DIGITAL_J1,
825 SPANTYPE_DIGITAL_BRI_NT,
826 SPANTYPE_DIGITAL_BRI_TE,
827 SPANTYPE_DIGITAL_BRI_SOFT,
828 SPANTYPE_DIGITAL_DYNAMIC,
829 };
830 const char *dahdi_spantype2str(enum spantypes st);
831 enum spantypes dahdi_str2spantype(const char *name);
832 const char *dahdi_lineconfig_bit_name(int lineconfig_bit);
833 ssize_t lineconfig_str(int lineconfig, char buf[], size_t size);
834
835 struct file;
836
837 struct dahdi_span_ops {
838 struct module *owner; /*!< Which module is exporting this span. */
839
840 /* ==== Span Callback Operations ==== */
841 /*! Req: Set the requested chunk size. This is the unit in which you must
842 report results for conferencing, etc */
843 int (*setchunksize)(struct dahdi_span *span, int chunksize);
844
845 /*! Opt: Configure the span (if appropriate) */
846 int (*spanconfig)(struct file *file, struct dahdi_span *span,
847 struct dahdi_lineconfig *lc);
848
849 /*! Opt: Start the span */
850 int (*startup)(struct file *file, struct dahdi_span *span);
851
852 /*! Opt: Shutdown the span */
853 int (*shutdown)(struct dahdi_span *span);
854
855 /*! Opt: Enable maintenance modes */
856 int (*maint)(struct dahdi_span *span, int mode);
857
858 #ifdef DAHDI_SYNC_TICK
859 /*! Opt: send sync to spans. Called in hard_irq context with chan_lock
860 * held.*/
861 void (*sync_tick)(struct dahdi_span *span, int is_master);
862 #endif
863 /* ==== Channel Callback Operations ==== */
864 /*! Opt: Set signalling type (if appropriate) */
865 int (*chanconfig)(struct file *file, struct dahdi_chan *chan,
866 int sigtype);
867
868 /*! Opt: Prepare a channel for I/O */
869 int (*open)(struct dahdi_chan *chan);
870
871 /*! Opt: Close channel for I/O */
872 int (*close)(struct dahdi_chan *chan);
873
874 /*! Opt: IOCTL */
875 int (*ioctl)(struct dahdi_chan *chan, unsigned int cmd, unsigned long data);
876
877 /* Okay, now we get to the signalling. You have several options: */
878
879 /* Option 1: If you're a T1 like interface, you can just provide a
880 rbsbits function and we'll assert robbed bits for you. Be sure to
881 set the DAHDI_FLAG_RBS in this case. */
882
883 /*! Opt: If the span uses A/B bits, set them here */
884 int (*rbsbits)(struct dahdi_chan *chan, int bits);
885
886 /*! Option 2: If you don't know about sig bits, but do have their
887 equivalents (i.e. you can disconnect battery, detect off hook,
888 generate ring, etc directly) then you can just specify a
889 sethook function, and we'll call you with appropriate hook states
890 to set. Still set the DAHDI_FLAG_RBS in this case as well */
891 int (*hooksig)(struct dahdi_chan *chan, enum dahdi_txsig hookstate);
892
893 /*! Option 3: If you can't use sig bits, you can write a function
894 which handles the individual hook states */
895 int (*sethook)(struct dahdi_chan *chan, int hookstate);
896
897 /*! Opt: Used to tell an onboard HDLC controller that there is data ready to transmit */
898 void (*hdlc_hard_xmit)(struct dahdi_chan *chan);
899
900 /*! If the watchdog detects no received data, it will call the
901 watchdog routine */
902 int (*watchdog)(struct dahdi_span *span, int cause);
903
904 #ifdef DAHDI_AUDIO_NOTIFY
905 /*! Opt: audio is used, don't optimize out */
906 int (*audio_notify)(struct dahdi_chan *chan, int yes);
907 #endif
908
909 /*! Opt: Enable preechocan stream from inline HW echocanceler. */
910 int (*enable_hw_preechocan)(struct dahdi_chan *chan);
911
912 /*! Opt: Disable preechocan stream from inline HW echocanceler. */
913 void (*disable_hw_preechocan)(struct dahdi_chan *chan);
914
915 /*! Opt: Dacs the contents of chan2 into chan1 if possible */
916 int (*dacs)(struct dahdi_chan *chan1, struct dahdi_chan *chan2);
917
918 /*! Opt: Provide echo cancellation on a channel */
919 int (*echocan_create)(struct dahdi_chan *chan,
920 struct dahdi_echocanparams *ecp,
921 struct dahdi_echocanparam *p,
922 struct dahdi_echocan_state **ec);
923
924 /*! Opt: Provide the name of the echo canceller on a channel */
925 const char *(*echocan_name)(const struct dahdi_chan *chan);
926
927 /*! When using "assigned spans", this function is called back when this
928 * span has been assigned with the system. */
929 void (*assigned)(struct dahdi_span *span);
930
931 /*! Called when the spantype / linemode is changed before the span is
932 * assigned a number. */
933 int (*set_spantype)(struct dahdi_span *span, enum spantypes st);
934 };
935
936 /**
937 * dahdi_device - Represents a device that can contain one or more spans.
938 *
939 * @spans: List of child spans.
940 * @manufacturer: Device manufacturer.
941 * @location: The location of this device. This should not change if
942 * the device is replaced (e.g: in the same PCI slot)
943 * @hardware_id: The hardware_id of this device (NULL for devices without
944 * a hardware_id). This should not change if the device is
945 * relocated to a different location (e.g: different PCI slot)
946 * @devicetype: What type of device this is.
947 * @irqmisses: Count of "interrupt misses" for this device.
948 *
949 */
950 struct dahdi_device {
951 struct list_head spans;
952 const char *manufacturer;
953 const char *location;
954 const char *hardware_id;
955 const char *devicetype;
956 struct device dev;
957 unsigned int irqmisses;
958 ktime_t registration_time;
959 };
960
961 struct dahdi_span {
962 spinlock_t lock;
963 char name[40]; /*!< Span name */
964 char desc[80]; /*!< Span description */
965 enum spantypes spantype; /*!< span type */
966 int deflaw; /*!< Default law (DAHDI_MULAW or DAHDI_ALAW) */
967 int alarms; /*!< Pending alarms on span */
968 unsigned long flags;
969 u8 cannot_provide_timing:1;
970 int lbo; /*!< Span Line-Buildout */
971 int lineconfig; /*!< Span line configuration */
972 int linecompat; /*!< Span line compatibility (0 for
973 analog spans)*/
974 int channels; /*!< Number of channels in span */
975 int txlevel; /*!< Tx level */
976 int rxlevel; /*!< Rx level */
977 int syncsrc; /*!< current sync src (gets copied here) */
978 struct dahdi_count count; /*!< Performance and Error counters */
979
980 int maintstat; /*!< Maintenance state */
981 int mainttimer; /*!< Maintenance timer */
982
983 struct dahdi_chan **chans; /*!< Member channel structures */
984
985 const struct dahdi_span_ops *ops; /*!< span callbacks. */
986
987 /* Used by DAHDI only -- no user servicable parts inside */
988 int spanno; /*!< Span number for DAHDI */
989 int offset; /*!< Offset within a given card */
990 int lastalarms; /*!< Previous alarms */
991
992 #ifdef CONFIG_DAHDI_WATCHDOG
993 int watchcounter;
994 int watchstate;
995 #endif
996
997 #ifdef CONFIG_PROC_FS
998 struct proc_dir_entry *proc_entry;
999 #endif
1000 struct list_head spans_node;
1001
1002 struct dahdi_device *parent;
1003 struct list_head device_node;
1004 struct device *span_device;
1005 };
1006
1007 struct dahdi_transcoder_channel {
1008 void *pvt;
1009 struct dahdi_transcoder *parent;
1010 wait_queue_head_t ready;
1011 __u32 built_fmts;
1012 #define DAHDI_TC_FLAG_BUSY 1
1013 #define DAHDI_TC_FLAG_CHAN_BUILT 2
1014 #define DAHDI_TC_FLAG_NONBLOCK 3
1015 #define DAHDI_TC_FLAG_DATA_WAITING 4
1016 unsigned long flags;
1017 u32 dstfmt;
1018 u32 srcfmt;
1019 };
1020
1021 int dahdi_is_sync_master(const struct dahdi_span *span);
1022 struct dahdi_span *get_master_span(void);
1023 void set_master_span(int spanno);
1024
1025 static inline int
1026 dahdi_tc_is_built(struct dahdi_transcoder_channel *dtc) {
1027 return test_bit(DAHDI_TC_FLAG_CHAN_BUILT, &dtc->flags);
1028 }
1029 static inline void
1030 dahdi_tc_set_built(struct dahdi_transcoder_channel *dtc) {
1031 set_bit(DAHDI_TC_FLAG_CHAN_BUILT, &dtc->flags);
1032 }
1033 static inline void
1034 dahdi_tc_clear_built(struct dahdi_transcoder_channel *dtc) {
1035 clear_bit(DAHDI_TC_FLAG_CHAN_BUILT, &dtc->flags);
1036 }
1037 static inline int
1038 dahdi_tc_is_nonblock(struct dahdi_transcoder_channel *dtc) {
1039 return test_bit(DAHDI_TC_FLAG_NONBLOCK, &dtc->flags);
1040 }
1041 static inline void
1042 dahdi_tc_set_nonblock(struct dahdi_transcoder_channel *dtc) {
1043 set_bit(DAHDI_TC_FLAG_NONBLOCK, &dtc->flags);
1044 }
1045 static inline void
1046 dahdi_tc_clear_nonblock(struct dahdi_transcoder_channel *dtc) {
1047 clear_bit(DAHDI_TC_FLAG_NONBLOCK, &dtc->flags);
1048 }
1049 static inline int
1050 dahdi_tc_is_data_waiting(struct dahdi_transcoder_channel *dtc) {
1051 return test_bit(DAHDI_TC_FLAG_DATA_WAITING, &dtc->flags);
1052 }
1053 static inline int
1054 dahdi_tc_is_busy(struct dahdi_transcoder_channel *dtc) {
1055 return test_bit(DAHDI_TC_FLAG_BUSY, &dtc->flags);
1056 }
1057 static inline void
1058 dahdi_tc_set_busy(struct dahdi_transcoder_channel *dtc) {
1059 set_bit(DAHDI_TC_FLAG_BUSY, &dtc->flags);
1060 }
1061 static inline void
1062 dahdi_tc_clear_busy(struct dahdi_transcoder_channel *dtc) {
1063 clear_bit(DAHDI_TC_FLAG_BUSY, &dtc->flags);
1064 }
1065 static inline void
1066 dahdi_tc_set_data_waiting(struct dahdi_transcoder_channel *dtc) {
1067 set_bit(DAHDI_TC_FLAG_DATA_WAITING, &dtc->flags);
1068 }
1069 static inline void
1070 dahdi_tc_clear_data_waiting(struct dahdi_transcoder_channel *dtc) {
1071 clear_bit(DAHDI_TC_FLAG_DATA_WAITING, &dtc->flags);
1072 }
1073
1074 struct dahdi_transcoder {
1075 struct list_head active_list_node;
1076 struct list_head registration_list_node;
1077 char name[80];
1078 int numchannels;
1079 unsigned int srcfmts;
1080 unsigned int dstfmts;
1081 struct file_operations fops;
1082 int (*allocate)(struct dahdi_transcoder_channel *channel);
1083 int (*release)(struct dahdi_transcoder_channel *channel);
1084 /* Transcoder channels */
1085 struct dahdi_transcoder_channel channels[0];
1086 };
1087
1088 #define DAHDI_WATCHDOG_NOINTS (1 << 0)
1089
1090 #define DAHDI_WATCHDOG_INIT 1000
1091
1092 #define DAHDI_WATCHSTATE_UNKNOWN 0
1093 #define DAHDI_WATCHSTATE_OK 1
1094 #define DAHDI_WATCHSTATE_RECOVERING 2
1095 #define DAHDI_WATCHSTATE_FAILED 3
1096
1097
1098 struct dahdi_dynamic {
1099 char addr[40];
1100 char dname[20];
1101 int err;
1102 struct kref kref;
1103 long rxjif;
1104 unsigned short txcnt;
1105 unsigned short rxcnt;
1106 struct dahdi_device *ddev;
1107 struct dahdi_span span;
1108 struct dahdi_chan *chans[256];
1109 struct dahdi_dynamic_driver *driver;
1110 void *pvt;
1111 int timing;
1112 int master;
1113 unsigned char *msgbuf;
1114 struct device *dev;
1115 int simulated_alarms;
1116
1117 struct list_head list;
1118 };
1119
1120 struct dahdi_dynamic_driver {
1121 /*! Driver name (e.g. Eth) */
1122 const char *name;
1123
1124 /*! Driver description */
1125 const char *desc;
1126
1127 /*! Create a new transmission pipe */
1128 int (*create)(struct dahdi_dynamic *d, const char *address);
1129
1130 /*! Destroy a created transmission pipe */
1131 void (*destroy)(struct dahdi_dynamic *d);
1132
1133 /*! Transmit a given message */
1134 void (*transmit)(struct dahdi_dynamic *d, u8 *msg, size_t msglen);
1135
1136 /*! Flush any pending messages */
1137 int (*flush)(void);
1138
1139 struct list_head list;
1140 struct module *owner;
1141
1142 /*! Numberic id of next device created by this driver. */
1143 unsigned int id;
1144 };
1145
1146 /*! \brief Receive a dynamic span message */
1147 void dahdi_dynamic_receive(struct dahdi_span *span, unsigned char *msg, int msglen);
1148
1149 /*! \brief Register a dynamic driver */
1150 int dahdi_dynamic_register_driver(struct dahdi_dynamic_driver *driver);
1151
1152 /*! \brief Unregister a dynamic driver */
1153 void dahdi_dynamic_unregister_driver(struct dahdi_dynamic_driver *driver);
1154
1155 int _dahdi_receive(struct dahdi_span *span);
1156
1157 /*! Receive on a span. The DAHDI interface will handle all the calculations for
1158 all member channels of the span, pulling the data from the readchunk buffer */
1159 static inline int dahdi_receive(struct dahdi_span *span)
1160 {
1161 unsigned long flags;
1162 int ret;
1163 local_irq_save(flags);
1164 ret = _dahdi_receive(span);
1165 local_irq_restore(flags);
1166 return ret;
1167 }
1168
1169 int _dahdi_transmit(struct dahdi_span *span);
1170
1171 /*! Prepare writechunk buffers on all channels for this span */
1172 static inline int dahdi_transmit(struct dahdi_span *span)
1173 {
1174 unsigned long flags;
1175 int ret;
1176 local_irq_save(flags);
1177 ret = _dahdi_transmit(span);
1178 local_irq_restore(flags);
1179 return ret;
1180 }
1181
1182 static inline int dahdi_is_digital_span(const struct dahdi_span *s)
1183 {
1184 return (s->linecompat > 0);
1185 }
1186
1187 static inline int dahdi_is_t1_span(const struct dahdi_span *s)
1188 {
1189 return (s->linecompat & (DAHDI_CONFIG_D4 | DAHDI_CONFIG_ESF |
1190 DAHDI_CONFIG_B8ZS)) > 0;
1191 }
1192
1193 static inline int dahdi_is_e1_span(const struct dahdi_span *s)
1194 {
1195 return dahdi_is_digital_span(s) && !dahdi_is_t1_span(s);
1196 }
1197
1198 /*! Abort the buffer currently being receive with event "event" */
1199 void dahdi_hdlc_abort(struct dahdi_chan *ss, int event);
1200
1201 /*! Indicate to DAHDI that the end of frame was received and rotate buffers */
1202 void dahdi_hdlc_finish(struct dahdi_chan *ss);
1203
1204 /*! Put a chunk of data into the current receive buffer */
1205 void dahdi_hdlc_putbuf(struct dahdi_chan *ss, unsigned char *rxb, int bytes);
1206
1207 /*! Get a chunk of data from the current transmit buffer. Returns -1 if no data
1208 * is left to send, 0 if there is data remaining in the current message to be sent
1209 * and 1 if the currently transmitted message is now done */
1210 int dahdi_hdlc_getbuf(struct dahdi_chan *ss, unsigned char *bufptr, unsigned int *size);
1211
1212 /*! Register a device. Returns 0 on success, -1 on failure. */
1213 struct dahdi_device *dahdi_create_device(void);
1214 int dahdi_register_device(struct dahdi_device *ddev, struct device *parent);
1215 void dahdi_unregister_device(struct dahdi_device *ddev);
1216 void dahdi_free_device(struct dahdi_device *ddev);
1217 void dahdi_init_span(struct dahdi_span *span);
1218
1219 /*! Find a span by its name and get a reference */
1220 struct dahdi_span *dahdi_span_find_by_name_and_get(const char *name);
1221
1222 /*! Allocate / free memory for a transcoder */
1223 struct dahdi_transcoder *dahdi_transcoder_alloc(int numchans);
1224 void dahdi_transcoder_free(struct dahdi_transcoder *ztc);
1225
1226 /*! \brief Register a transcoder */
1227 int dahdi_transcoder_register(struct dahdi_transcoder *tc);
1228
1229 /*! \brief Unregister a transcoder */
1230 int dahdi_transcoder_unregister(struct dahdi_transcoder *tc);
1231
1232 /*! \brief Alert a transcoder */
1233 int dahdi_transcoder_alert(struct dahdi_transcoder_channel *ztc);
1234
1235 /*! \brief Gives a name to an LBO */
1236 const char *dahdi_lboname(int lbo);
1237
1238 /*! \brief Tell DAHDI about changes in received rbs bits */
1239 void dahdi_rbsbits(struct dahdi_chan *chan, int bits);
1240
1241 /*! \brief Tell DAHDI abou changes in received signalling */
1242 void dahdi_hooksig(struct dahdi_chan *chan, enum dahdi_rxsig rxsig);
1243
1244 /*! \brief Queue an event on a channel */
1245 void dahdi_qevent_nolock(struct dahdi_chan *chan, int event);
1246
1247 /*! \brief Queue an event on a channel, locking it first */
1248 void dahdi_qevent_lock(struct dahdi_chan *chan, int event);
1249
1250 /*! \brief Notify a change possible change in alarm status on a channel */
1251 void dahdi_alarm_channel(struct dahdi_chan *chan, int alarms);
1252
1253 /*! \brief Notify a change possible change in alarm status on a span */
1254 void dahdi_alarm_notify(struct dahdi_span *span);
1255
1256 /*! \brief Initialize a tone state */
1257 void dahdi_init_tone_state(struct dahdi_tone_state *ts, struct dahdi_tone *zt);
1258
1259 /*! \brief Get a given MF tone struct, suitable for dahdi_tone_nextsample. */
1260 struct dahdi_tone *dahdi_mf_tone(const struct dahdi_chan *chan, char digit, int digitmode);
1261
1262 /*! \brief Convert signalling bits to human readable string */
1263 const char *sigstr(int sig);
1264
1265 /*! \brief Convert alarm bits to human readable string */
1266 int fill_alarm_string(char *buf, int count, int alarms);
1267
1268 /* Echo cancel a receive and transmit chunk for a given channel. This
1269 should be called by the low-level driver as close to the interface
1270 as possible. ECHO CANCELLATION IS NO LONGER AUTOMATICALLY DONE
1271 AT THE DAHDI LEVEL. dahdi_ec_chunk will not echo cancel if it should
1272 not be doing so. rxchunk is modified in-place */
1273 void __dahdi_ec_chunk(struct dahdi_chan *ss, u8 *rxchunk,
1274 const u8 *preecchunk, const u8 *txchunk);
1275
1276 static inline void _dahdi_ec_chunk(struct dahdi_chan *chan,
1277 u8 *rxchunk, const u8 *txchunk)
1278 {
1279 __dahdi_ec_chunk(chan, rxchunk, rxchunk, txchunk);
1280 }
1281
1282 static inline void dahdi_ec_chunk(struct dahdi_chan *ss, unsigned char *rxchunk,
1283 const unsigned char *txchunk)
1284 {
1285 unsigned long flags;
1286 local_irq_save(flags);
1287 _dahdi_ec_chunk(ss, rxchunk, txchunk);
1288 local_irq_restore(flags);
1289 }
1290
1291 void _dahdi_ec_span(struct dahdi_span *span);
1292 static inline void dahdi_ec_span(struct dahdi_span *span)
1293 {
1294 unsigned long flags;
1295 local_irq_save(flags);
1296 _dahdi_ec_span(span);
1297 local_irq_restore(flags);
1298 }
1299
1300 extern struct file_operations *dahdi_transcode_fops;
1301 extern struct file_operations *dahdi_trunkdev_fops;
1302
1303 int dahdi_get_auto_assign_spans(void);
1304
1305 /* Don't use these directly -- they're not guaranteed to
1306 be there. */
1307 extern short __dahdi_mulaw[256];
1308 extern short __dahdi_alaw[256];
1309 #ifdef CONFIG_CALC_XLAW
1310 u_char __dahdi_lineartoulaw(short a);
1311 u_char __dahdi_lineartoalaw(short a);
1312 #else
1313 extern u_char __dahdi_lin2mu[16384];
1314 extern u_char __dahdi_lin2a[16384];
1315 #endif
1316
1317 struct dahdi_dynamic_ops {
1318 struct module *owner;
1319 int (*ioctl)(unsigned int cmd, unsigned long data);
1320 };
1321
1322 /*! \brief Used by dynamic DAHDI -- don't use directly */
1323 void dahdi_set_dynamic_ops(const struct dahdi_dynamic_ops *ops);
1324
1325 /*! \brief Used by DAHDI HPEC module -- don't use directly */
1326 void dahdi_set_hpec_ioctl(int (*func)(unsigned int cmd, unsigned long data));
1327
1328 /*! \brief Used privately by DAHDI. Avoid touching directly */
1329 struct dahdi_tone {
1330 int fac1;
1331 int init_v2_1;
1332 int init_v3_1;
1333
1334 int fac2;
1335 int init_v2_2;
1336 int init_v3_2;
1337
1338 int tonesamples; /*!< How long to play this tone before
1339 going to the next (in samples) */
1340 struct dahdi_tone *next; /* Next tone in this sequence */
1341
1342 int modulate;
1343 };
1344
1345 static inline short dahdi_tone_nextsample(struct dahdi_tone_state *ts, struct dahdi_tone *zt)
1346 {
1347 /* follow the curves, return the sum */
1348
1349 int p;
1350
1351 ts->v1_1 = ts->v2_1;
1352 ts->v2_1 = ts->v3_1;
1353 ts->v3_1 = (zt->fac1 * ts->v2_1 >> 15) - ts->v1_1;
1354
1355 ts->v1_2 = ts->v2_2;
1356 ts->v2_2 = ts->v3_2;
1357 ts->v3_2 = (zt->fac2 * ts->v2_2 >> 15) - ts->v1_2;
1358
1359 /* Return top 16 bits */
1360 if (!ts->modulate) return ts->v3_1 + ts->v3_2;
1361 /* we are modulating */
1362 p = ts->v3_2 - 32768;
1363 if (p < 0) p = -p;
1364 p = ((p * 9) / 10) + 1;
1365 return (ts->v3_1 * p) >> 15;
1366
1367 }
1368
1369 static inline short dahdi_txtone_nextsample(struct dahdi_chan *ss)
1370 {
1371 /* follow the curves, return the sum */
1372
1373 ss->v1_1 = ss->v2_1;
1374 ss->v2_1 = ss->v3_1;
1375 ss->v3_1 = (ss->txtone * ss->v2_1 >> 15) - ss->v1_1;
1376 return ss->v3_1;
1377 }
1378
1379 /* These are the right functions to use. */
1380
1381 #define DAHDI_MULAW(a) (__dahdi_mulaw[(a)])
1382 #define DAHDI_ALAW(a) (__dahdi_alaw[(a)])
1383 #define DAHDI_XLAW(a,c) (c->xlaw[(a)])
1384
1385 #ifdef CONFIG_CALC_XLAW
1386 #define DAHDI_LIN2MU(a) (__dahdi_lineartoulaw((a)))
1387 #define DAHDI_LIN2A(a) (__dahdi_lineartoalaw((a)))
1388
1389 #define DAHDI_LIN2X(a,c) ((c)->lineartoxlaw((a)))
1390
1391 #else
1392 /* Use tables */
1393 #define DAHDI_LIN2MU(a) (__dahdi_lin2mu[((unsigned short)(a)) >> 2])
1394 #define DAHDI_LIN2A(a) (__dahdi_lin2a[((unsigned short)(a)) >> 2])
1395
1396 /* Manipulate as appropriate for x-law */
1397 #define DAHDI_LIN2X(a,c) ((c)->lin2x[((unsigned short)(a)) >> 2])
1398
1399 #endif /* CONFIG_CALC_XLAW */
1400
1401 /* Data formats for capabilities and frames alike (from Asterisk) */
1402 /*! G.723.1 compression */
1403 #define DAHDI_FORMAT_G723_1 (1 << 0)
1404 /*! GSM compression */
1405 #define DAHDI_FORMAT_GSM (1 << 1)
1406 /*! Raw mu-law data (G.711) */
1407 #define DAHDI_FORMAT_ULAW (1 << 2)
1408 /*! Raw A-law data (G.711) */
1409 #define DAHDI_FORMAT_ALAW (1 << 3)
1410 /*! ADPCM (G.726, 32kbps) */
1411 #define DAHDI_FORMAT_G726 (1 << 4)
1412 /*! ADPCM (IMA) */
1413 #define DAHDI_FORMAT_ADPCM (1 << 5)
1414 /*! Raw 16-bit Signed Linear (8000 Hz) PCM */
1415 #define DAHDI_FORMAT_SLINEAR (1 << 6)
1416 /*! LPC10, 180 samples/frame */
1417 #define DAHDI_FORMAT_LPC10 (1 << 7)
1418 /*! G.729A audio */
1419 #define DAHDI_FORMAT_G729A (1 << 8)
1420 /*! SpeeX Free Compression */
1421 #define DAHDI_FORMAT_SPEEX (1 << 9)
1422 /*! iLBC Free Compression */
1423 #define DAHDI_FORMAT_ILBC (1 << 10)
1424 /*! Maximum audio format */
1425 #define DAHDI_FORMAT_MAX_AUDIO (1 << 15)
1426 /*! Maximum audio mask */
1427 #define DAHDI_FORMAT_AUDIO_MASK ((1 << 16) - 1)
1428
1429 #if LINUX_VERSION_CODE > KERNEL_VERSION(6,5,12)
1430 #undef flush_scheduled_work
1431 #define flush_scheduled_work() \
1432 ({ \
1433 if (0) \
1434 __warn_flushing_systemwide_wq(); \
1435 __flush_workqueue(system_wq); \
1436 })
1437 #endif
1438
1439 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
1440
1441 #ifndef TIMER_DATA_TYPE
1442 #define TIMER_DATA_TYPE unsigned long
1443 #endif
1444
1445 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0)
1446
1447 #ifdef RHEL_RELEASE_VERSION
1448 #if RHEL_RELEASE_CODE > RHEL_RELEASE_VERSION(7, 5)
1449 #define DAHDI_HAVE_TIMER_SETUP
1450 #undef TIMER_DATA_TYPE
1451 #define TIMER_DATA_TYPE struct timer_list *
1452 #endif
1453 #endif
1454
1455 #ifndef DAHDI_HAVE_TIMER_SETUP
1456 /**
1457 * timer_setup - Added in 4.13.0. We can make a direct translation to the
1458 * setup_timer interface since DAHDI does not pass any flags to any of the
1459 * timer_setup functions.
1460 *
1461 */
1462 static inline void
1463 timer_setup(struct timer_list *timer,
1464 void (*timer_callback)(TIMER_DATA_TYPE data),
1465 unsigned long flags)
1466 {
1467 WARN_ON(flags != 0);
1468 setup_timer(timer, timer_callback, (TIMER_DATA_TYPE)timer);
1469 }
1470
1471 #define from_timer(var, callback_timer, timer_fieldname) \
1472 container_of((struct timer_list *)(callback_timer), \
1473 typeof(*var), timer_fieldname)
1474
1475 #endif
1476
1477 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)
1478 #define refcount_read atomic_read
1479
1480 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)
1481 #define dahdi_ktime_equal ktime_equal
1482
1483 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)
1484
1485 #ifdef RHEL_RELEASE_VERSION
1486 #if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6, 8)
1487 #define DAHDI_HAVE_KTIME_MS_DELTA
1488 #endif
1489 #endif
1490
1491 #ifndef DAHDI_HAVE_KTIME_MS_DELTA
1492 static inline s64 dahdi_ktime_to_ms(const ktime_t kt)
1493 {
1494 struct timeval tv = ktime_to_timeval(kt);
1495
1496 return (s64) tv.tv_sec * MSEC_PER_SEC + tv.tv_usec / USEC_PER_MSEC;
1497 }
1498
1499 static inline s64 ktime_ms_delta(const ktime_t later, const ktime_t earlier)
1500 {
1501 return dahdi_ktime_to_ms(ktime_sub(later, earlier));
1502 }
1503 #else
1504 #undef DAHDI_HAVE_KTIME_MS_DELTA
1505 #endif
1506
1507 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0)
1508
1509 /* DAHDI only was using the xxx_clear_bit variants. */
1510 #ifndef smp_mb__before_atomic
1511 #define smp_mb__before_atomic smp_mb__before_clear_bit
1512 #endif
1513
1514 #ifndef smp_mb__after_atomic
1515 #define smp_mb__after_atomic smp_mb__after_clear_bit
1516 #endif
1517
1518 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 0)
1519 #ifdef RHEL_RELEASE_VERSION
1520 #if RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(6, 5)
1521 #ifdef CONFIG_PROC_FS
1522 #include <linux/proc_fs.h>
1523 static inline void *PDE_DATA(const struct inode *inode)
1524 {
1525 return PDE(inode)->data;
1526 }
1527 #endif
1528 #endif
1529 #else
1530 #ifdef CONFIG_PROC_FS
1531 #include <linux/proc_fs.h>
1532 static inline void *PDE_DATA(const struct inode *inode)
1533 {
1534 return PDE(inode)->data;
1535 }
1536 #endif
1537 #endif
1538 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31)
1539
1540 #define KERN_CONT ""
1541
1542 #endif /* 2.6.31 */
1543 #endif /* 3.10.0 */
1544 #endif /* 3.16.0 */
1545 #endif /* 4.0.0 */
1546 #endif /* 4.10.0 */
1547 #endif /* 4.11.0 */
1548 #endif /* 4.13.0 */
1549 #else /* >= 4.15.0 */
1550
1551 #ifndef TIMER_DATA_TYPE
1552 #define TIMER_DATA_TYPE struct timer_list *
1553 #endif
1554
1555 #endif /* 4.15.0 */
1556
1557 #ifndef dahdi_ktime_equal
1558 static inline int dahdi_ktime_equal(const ktime_t cmp1, const ktime_t cmp2)
1559 {
1560 return cmp1 == cmp2;
1561 }
1562 #endif
1563
1564 #ifndef DEFINE_SPINLOCK
1565 #define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED
1566 #endif
1567
1568 #if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0)
1569 #ifndef DEFINE_SEMAPHORE
1570 #define DEFINE_SEMAPHORE(name) \
1571 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
1572 #endif
1573 #else /* 6.4.0, speficcally 48380368dec14859723b9e3fbd43e042638d9a76 */
1574 #undef DEFINE_SEMAPHORE
1575 #define DEFINE_SEMAPHORE(name) \
1576 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
1577 #endif
1578
1579 #ifndef DEFINE_MUTEX
1580 struct mutex {
1581 struct semaphore sem;
1582 };
1583 #define DEFINE_MUTEX(name) \
1584 struct mutex name = { \
1585 .sem = __SEMAPHORE_INITIALIZER((name).sem, 1), \
1586 }
1587 #define mutex_lock(_x) down(&(_x)->sem)
1588 #define mutex_unlock(_x) up(&(_x)->sem)
1589 #define mutex_init(_x) sema_init(&(_x)->sem, 1)
1590 #endif
1591
1592 #ifndef DEFINE_PCI_DEVICE_TABLE
1593 #define DEFINE_PCI_DEVICE_TABLE(_x) \
1594 const struct pci_device_id _x[] __devinitdata
1595 #endif
1596
1597 #ifndef DMA_BIT_MASK
1598 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
1599 #endif
1600
1601 /* WARN_ONCE first showed up in the kernel in 2.6.27 but it may have been
1602 * backported. */
1603 #ifndef WARN_ONCE
1604 #define WARN_ONCE(condition, format...) WARN_ON_ONCE(condition)
1605 #endif
1606
1607 #define DAHDI_CTL 0
1608 #define DAHDI_TRANSCODE 250
1609 #define DAHDI_TRUNKDEV 252
1610 #define DAHDI_TIMER 253
1611 #define DAHDI_CHANNEL 254
1612 #define DAHDI_PSEUDO 255
1613
1614 /* prink-wrapper macros */
1615
1616 #define module_printk(level, fmt, args...) \
1617 printk(level "%s: " fmt, THIS_MODULE->name, ## args)
1618
1619 #define DAHDI_PRINTK(level, category, fmt, ...) \
1620 printk(KERN_ ## level "%s%s-%s: " fmt, #level, category, \
1621 THIS_MODULE->name, ## __VA_ARGS__)
1622 #define span_printk(level, category, span, fmt, ...) \
1623 printk(KERN_ ## level "%s%s-%s: span-%d: " fmt, #level, \
1624 category, THIS_MODULE->name, (span)->spanno, ## __VA_ARGS__)
1625 #define chan_printk(level, category, chan, fmt, ...) \
1626 printk(KERN_ ## level "%s%s-%s: chan-%d: " fmt, #level, \
1627 category, THIS_MODULE->name, (chan)->channo, ## __VA_ARGS__)
1628 #define dahdi_err(fmt, ...) DAHDI_PRINTK(ERR, "", fmt, ## __VA_ARGS__)
1629 #define span_info(span, fmt, ...) span_printk(INFO, "", span, fmt, \
1630 ## __VA_ARGS__)
1631 #define span_notice(span, fmt, ...) span_printk(NOTICE, "", span, fmt, \
1632 ## __VA_ARGS__)
1633 #define span_err(span, fmt, ...) span_printk(ERR, "", span, fmt, \
1634 ## __VA_ARGS__)
1635 #define chan_notice(chan, fmt, ...) chan_printk(NOTICE, "", chan, fmt, \
1636 ## __VA_ARGS__)
1637 #define chan_err(chan, fmt, ...) chan_printk(ERR, "", chan, fmt, \
1638 ## __VA_ARGS__)
1639
1640 #ifndef pr_fmt
1641 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
1642 #endif
1643
1644 #ifndef pr_err
1645 #define pr_err(fmt, ...) \
1646 printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
1647 #endif
1648 #ifndef pr_warning
1649 #define pr_warning(fmt, ...) \
1650 printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
1651 #endif
1652 #ifndef pr_warn
1653 #define pr_warn pr_warning
1654 #endif
1655 #ifndef pr_notice
1656 #define pr_notice(fmt, ...) \
1657 printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
1658 #endif
1659 #ifndef pr_info
1660 #define pr_info(fmt, ...) \
1661 printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
1662 #endif
1663
1664 /* If KBUILD_MODNAME is not defined in a compilation unit, then the dev_dbg
1665 * macro will not work properly. */
1666 #ifndef KBUILD_MODNAME
1667 #undef dev_dbg
1668 #ifdef DEBUG
1669 #define dev_dbg dev_info
1670 #else
1671 #define dev_dbg(...) do { } while (0)
1672 #endif
1673 #endif
1674
1675 /* The dbg_* ones use a magical variable 'debug' and the user should be
1676 * aware of that.
1677 */
1678 #ifdef DAHDI_PRINK_MACROS_USE_debug
1679 #ifndef BIT /* added in 2.6.24 */
1680 #define BIT(i) (1UL << (i))
1681 #endif
1682 /* Standard debug bit values. Any module may define others. They must
1683 * be of the form DAHDI_DBG_*
1684 */
1685 #define DAHDI_DBG_GENERAL BIT(0)
1686 #define DAHDI_DBG_ASSIGN BIT(1)
1687 #define DAHDI_DBG_DEVICES BIT(7) /* instantiation/destruction etc. */
1688 #define dahdi_dbg(bits, fmt, ...) \
1689 ((void)((debug & (DAHDI_DBG_ ## bits)) && DAHDI_PRINTK(DEBUG, \
1690 "-" #bits, "%s: " fmt, __func__, ## __VA_ARGS__)))
1691 #define span_dbg(bits, span, fmt, ...) \
1692 ((void)((debug & (DAHDI_DBG_ ## bits)) && \
1693 span_printk(DEBUG, "-" #bits, span, "%s: " \
1694 fmt, __func__, ## __VA_ARGS__)))
1695 #define chan_dbg(bits, chan, fmt, ...) \
1696 ((void)((debug & (DAHDI_DBG_ ## bits)) && \
1697 chan_printk(DEBUG, "-" #bits, chan, \
1698 "%s: " fmt, __func__, ## __VA_ARGS__)))
1699 #define dahdi_dev_dbg(bits, dev, fmt, ...) \
1700 do { if (debug & (DAHDI_DBG_ ## bits)) { \
1701 dev_printk(KERN_DEBUG, dev, \
1702 "DBG-%s(%s): " fmt, #bits, __func__, ## __VA_ARGS__); \
1703 } } while (0)
1704
1705 #endif /* DAHDI_PRINK_MACROS_USE_debug */
1706
1707
1708 /* work-around kernel API change from "struct device *dev" to "const struct device *dev"
1709 * as implemented in 2a81ada32f0e584fc0c943e0d3a8c9f4fae411d6 */
1710 #if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
1711 #define UEVENT_CONST const
1712 #else
1713 #define UEVENT_CONST
1714 #endif
1715
1716 #endif /* _DAHDI_KERNEL_H */