\doxysection{i460\+\_\+mux.\+h}
\label{i460__mux_8h_source}\index{include/osmocom/isdn/i460\_mux.h@{include/osmocom/isdn/i460\_mux.h}}
\textbf{ Go to the documentation of this file.}
\begin{DoxyCode}{0}
\DoxyCodeLine{1 }
\DoxyCodeLine{3 \textcolor{comment}{/*}}
\DoxyCodeLine{4 \textcolor{comment}{ * (C) 2020 by Harald Welte <laforge@gnumonks.org>}}
\DoxyCodeLine{5 \textcolor{comment}{ *}}
\DoxyCodeLine{6 \textcolor{comment}{ * SPDX-\/License-\/Identifier: GPL-\/2.0+}}
\DoxyCodeLine{7 \textcolor{comment}{ *}}
\DoxyCodeLine{8 \textcolor{comment}{ *  This program is free software; you can redistribute it and/or modify}}
\DoxyCodeLine{9 \textcolor{comment}{ *  it under the terms of the GNU General Public License as published by}}
\DoxyCodeLine{10 \textcolor{comment}{ *  the Free Software Foundation; either version 2 of the License, or}}
\DoxyCodeLine{11 \textcolor{comment}{ *  (at your option) any later version.}}
\DoxyCodeLine{12 \textcolor{comment}{ *}}
\DoxyCodeLine{13 \textcolor{comment}{ *  This program is distributed in the hope that it will be useful,}}
\DoxyCodeLine{14 \textcolor{comment}{ *  but WITHOUT ANY WARRANTY; without even the implied warranty of}}
\DoxyCodeLine{15 \textcolor{comment}{ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the}}
\DoxyCodeLine{16 \textcolor{comment}{ *  GNU General Public License for more details.}}
\DoxyCodeLine{17 \textcolor{comment}{ */}}
\DoxyCodeLine{18 }
\DoxyCodeLine{19 \textcolor{preprocessor}{\#pragma once}}
\DoxyCodeLine{20 \textcolor{preprocessor}{\#include <stdint.h>}}
\DoxyCodeLine{21 \textcolor{preprocessor}{\#include <osmocom/core/bits.h>}}
\DoxyCodeLine{22 \textcolor{preprocessor}{\#include <osmocom/core/linuxlist.h>}}
\DoxyCodeLine{23 \textcolor{preprocessor}{\#include <osmocom/core/msgb.h>}}
\DoxyCodeLine{24 }
\DoxyCodeLine{25 \textcolor{preprocessor}{\#define OSMO\_I460\_NUM\_SUBCHAN 8}}
\DoxyCodeLine{26 }
\DoxyCodeLine{27 \textcolor{comment}{/* I.460 sub-\/slot rate */}}
\DoxyCodeLine{28 \textcolor{keyword}{enum} osmo\_i460\_rate \{}
\DoxyCodeLine{29         OSMO\_I460\_RATE\_NONE,         \textcolor{comment}{/* disabled */}}
\DoxyCodeLine{30         OSMO\_I460\_RATE\_64k,}
\DoxyCodeLine{31         OSMO\_I460\_RATE\_32k,}
\DoxyCodeLine{32         OSMO\_I460\_RATE\_16k,}
\DoxyCodeLine{33         OSMO\_I460\_RATE\_8k,}
\DoxyCodeLine{34 \};}
\DoxyCodeLine{35 }
\DoxyCodeLine{36 \textcolor{keyword}{struct }osmo\_i460\_subchan;}
\DoxyCodeLine{37 }
\DoxyCodeLine{38 \textcolor{keyword}{typedef} void (*out\_cb\_bits\_t)(\textcolor{keyword}{struct }osmo\_i460\_subchan *schan, \textcolor{keywordtype}{void} *user\_data,}
\DoxyCodeLine{39                               \textcolor{keyword}{const} ubit\_t *bits, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} num\_bits);}
\DoxyCodeLine{40 \textcolor{keyword}{typedef} void (*out\_cb\_bytes\_t)(\textcolor{keyword}{struct }osmo\_i460\_subchan *schan, \textcolor{keywordtype}{void} *user\_data,}
\DoxyCodeLine{41                                \textcolor{keyword}{const} uint8\_t *bytes, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} num\_bytes);}
\DoxyCodeLine{42 }
\DoxyCodeLine{43 \textcolor{keyword}{struct }osmo\_i460\_subchan\_demux \{}
\DoxyCodeLine{45         uint8\_t *out\_bitbuf;}
\DoxyCodeLine{47         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} out\_bitbuf\_size;}
\DoxyCodeLine{49         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} out\_idx;}
\DoxyCodeLine{51         out\_cb\_bits\_t out\_cb\_bits;}
\DoxyCodeLine{52         out\_cb\_bytes\_t out\_cb\_bytes;}
\DoxyCodeLine{53         \textcolor{keywordtype}{void} *user\_data;}
\DoxyCodeLine{54 \};}
\DoxyCodeLine{55 }
\DoxyCodeLine{56 \textcolor{keyword}{typedef} void (*in\_cb\_queue\_empty\_t)(\textcolor{keyword}{struct }osmo\_i460\_subchan *schan, \textcolor{keywordtype}{void} *user\_data);}
\DoxyCodeLine{57 }
\DoxyCodeLine{58 \textcolor{keyword}{struct }osmo\_i460\_subchan\_mux \{}
\DoxyCodeLine{60         \textcolor{keyword}{struct }llist\_head tx\_queue;}
\DoxyCodeLine{61         in\_cb\_queue\_empty\_t in\_cb\_queue\_empty;}
\DoxyCodeLine{62         \textcolor{keywordtype}{void} *user\_data;}
\DoxyCodeLine{63 \};}
\DoxyCodeLine{64 }
\DoxyCodeLine{65 \textcolor{keyword}{struct }osmo\_i460\_subchan \{}
\DoxyCodeLine{66         \textcolor{keyword}{struct }osmo\_i460\_timeslot *ts;      \textcolor{comment}{/* back-\/pointer */}}
\DoxyCodeLine{67         \textcolor{keyword}{enum} osmo\_i460\_rate rate;             \textcolor{comment}{/* 8/16/32/64k */}}
\DoxyCodeLine{68         uint8\_t bit\_offset;           \textcolor{comment}{/* bit offset inside each byte of the B-\/channel */}}
\DoxyCodeLine{69         \textcolor{keyword}{struct }osmo\_i460\_subchan\_demux demux;}
\DoxyCodeLine{70         \textcolor{keyword}{struct }osmo\_i460\_subchan\_mux mux;}
\DoxyCodeLine{71 \};}
\DoxyCodeLine{72 }
\DoxyCodeLine{73 \textcolor{keyword}{struct }osmo\_i460\_timeslot \{}
\DoxyCodeLine{74         \textcolor{keyword}{struct }osmo\_i460\_subchan schan[OSMO\_I460\_NUM\_SUBCHAN];}
\DoxyCodeLine{75 \};}
\DoxyCodeLine{76 }
\DoxyCodeLine{78 \textcolor{keyword}{struct }osmo\_i460\_schan\_desc \{}
\DoxyCodeLine{79         \textcolor{keyword}{enum} osmo\_i460\_rate rate;}
\DoxyCodeLine{80         uint8\_t bit\_offset;}
\DoxyCodeLine{81         \textcolor{keyword}{struct }\{}
\DoxyCodeLine{82                 \textcolor{comment}{/* size (in bits) of the internal buffer; determines granularity */}}
\DoxyCodeLine{83                 \textcolor{keywordtype}{size\_t} num\_bits;}
\DoxyCodeLine{85                 out\_cb\_bits\_t out\_cb\_bits;}
\DoxyCodeLine{92                 out\_cb\_bytes\_t out\_cb\_bytes;}
\DoxyCodeLine{93                 \textcolor{comment}{/* opaque user data pointer to pass to out\_cb */}}
\DoxyCodeLine{94                 \textcolor{keywordtype}{void} *user\_data;}
\DoxyCodeLine{95         \} demux;}
\DoxyCodeLine{96 }
\DoxyCodeLine{97         \textcolor{keyword}{struct }\{}
\DoxyCodeLine{98                 \textcolor{comment}{/* call-\/back function whenever the muxer requires more input data from the sub-\/channels,}}
\DoxyCodeLine{99 \textcolor{comment}{                 * but has nothing enqueued yet. A typical function would then call osmo\_i460\_mux\_enqueue() */}}
\DoxyCodeLine{100                 in\_cb\_queue\_empty\_t in\_cb\_queue\_empty;}
\DoxyCodeLine{101                 \textcolor{comment}{/* opaque user data pointer to pass to in\_cb */}}
\DoxyCodeLine{102                 \textcolor{keywordtype}{void} *user\_data;}
\DoxyCodeLine{103         \} mux;}
\DoxyCodeLine{104 \};}
\DoxyCodeLine{105 }
\DoxyCodeLine{106 \textcolor{keywordtype}{void} osmo\_i460\_demux\_in(\textcolor{keyword}{struct} osmo\_i460\_timeslot *ts, \textcolor{keyword}{const} uint8\_t *data, \textcolor{keywordtype}{size\_t} data\_len);}
\DoxyCodeLine{107 }
\DoxyCodeLine{108 \textcolor{keywordtype}{void} osmo\_i460\_mux\_enqueue(\textcolor{keyword}{struct} osmo\_i460\_subchan *schan, \textcolor{keyword}{struct} msgb *msg);}
\DoxyCodeLine{109 \textcolor{keywordtype}{int} osmo\_i460\_mux\_out(\textcolor{keyword}{struct} osmo\_i460\_timeslot *ts, uint8\_t *out, \textcolor{keywordtype}{size\_t} out\_len);}
\DoxyCodeLine{110 }
\DoxyCodeLine{111 \textcolor{keywordtype}{void} osmo\_i460\_ts\_init(\textcolor{keyword}{struct} osmo\_i460\_timeslot *ts);}
\DoxyCodeLine{112 }
\DoxyCodeLine{113 \textcolor{keyword}{struct }osmo\_i460\_subchan *}
\DoxyCodeLine{114 osmo\_i460\_subchan\_add(\textcolor{keywordtype}{void} *ctx, \textcolor{keyword}{struct} osmo\_i460\_timeslot *ts, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_i460\_schan\_desc *chd);}
\DoxyCodeLine{115 }
\DoxyCodeLine{116 \textcolor{keywordtype}{void} osmo\_i460\_subchan\_del(\textcolor{keyword}{struct} osmo\_i460\_subchan *schan);}
\DoxyCodeLine{117 }
\DoxyCodeLine{118 \textcolor{keywordtype}{int} osmo\_i460\_subchan\_count(\textcolor{keyword}{struct} osmo\_i460\_timeslot *ts);}
\DoxyCodeLine{119 }

\end{DoxyCode}
