15a5e045bSMauro Carvalho Chehab=========================================
25a5e045bSMauro Carvalho ChehabKernel CAPI Interface to Hardware Drivers
35a5e045bSMauro Carvalho Chehab=========================================
45a5e045bSMauro Carvalho Chehab
55a5e045bSMauro Carvalho Chehab1. Overview
65a5e045bSMauro Carvalho Chehab===========
75a5e045bSMauro Carvalho Chehab
85a5e045bSMauro Carvalho ChehabFrom the CAPI 2.0 specification:
95a5e045bSMauro Carvalho ChehabCOMMON-ISDN-API (CAPI) is an application programming interface standard used
105a5e045bSMauro Carvalho Chehabto access ISDN equipment connected to basic rate interfaces (BRI) and primary
115a5e045bSMauro Carvalho Chehabrate interfaces (PRI).
125a5e045bSMauro Carvalho Chehab
135a5e045bSMauro Carvalho ChehabKernel CAPI operates as a dispatching layer between CAPI applications and CAPI
145a5e045bSMauro Carvalho Chehabhardware drivers. Hardware drivers register ISDN devices (controllers, in CAPI
155a5e045bSMauro Carvalho Chehablingo) with Kernel CAPI to indicate their readiness to provide their service
165a5e045bSMauro Carvalho Chehabto CAPI applications. CAPI applications also register with Kernel CAPI,
175a5e045bSMauro Carvalho Chehabrequesting association with a CAPI device. Kernel CAPI then dispatches the
185a5e045bSMauro Carvalho Chehabapplication registration to an available device, forwarding it to the
195a5e045bSMauro Carvalho Chehabcorresponding hardware driver. Kernel CAPI then forwards CAPI messages in both
205a5e045bSMauro Carvalho Chehabdirections between the application and the hardware driver.
215a5e045bSMauro Carvalho Chehab
225a5e045bSMauro Carvalho ChehabFormat and semantics of CAPI messages are specified in the CAPI 2.0 standard.
235a5e045bSMauro Carvalho ChehabThis standard is freely available from https://www.capi.org.
245a5e045bSMauro Carvalho Chehab
255a5e045bSMauro Carvalho Chehab
265a5e045bSMauro Carvalho Chehab2. Driver and Device Registration
275a5e045bSMauro Carvalho Chehab=================================
285a5e045bSMauro Carvalho Chehab
295a5e045bSMauro Carvalho ChehabCAPI drivers must register each of the ISDN devices they control with Kernel
305a5e045bSMauro Carvalho ChehabCAPI by calling the Kernel CAPI function attach_capi_ctr() with a pointer to a
315a5e045bSMauro Carvalho Chehabstruct capi_ctr before they can be used. This structure must be filled with
325a5e045bSMauro Carvalho Chehabthe names of the driver and controller, and a number of callback function
335a5e045bSMauro Carvalho Chehabpointers which are subsequently used by Kernel CAPI for communicating with the
345a5e045bSMauro Carvalho Chehabdriver. The registration can be revoked by calling the function
355a5e045bSMauro Carvalho Chehabdetach_capi_ctr() with a pointer to the same struct capi_ctr.
365a5e045bSMauro Carvalho Chehab
375a5e045bSMauro Carvalho ChehabBefore the device can be actually used, the driver must fill in the device
385a5e045bSMauro Carvalho Chehabinformation fields 'manu', 'version', 'profile' and 'serial' in the capi_ctr
395a5e045bSMauro Carvalho Chehabstructure of the device, and signal its readiness by calling capi_ctr_ready().
405a5e045bSMauro Carvalho ChehabFrom then on, Kernel CAPI may call the registered callback functions for the
415a5e045bSMauro Carvalho Chehabdevice.
425a5e045bSMauro Carvalho Chehab
435a5e045bSMauro Carvalho ChehabIf the device becomes unusable for any reason (shutdown, disconnect ...), the
445a5e045bSMauro Carvalho Chehabdriver has to call capi_ctr_down(). This will prevent further calls to the
455a5e045bSMauro Carvalho Chehabcallback functions by Kernel CAPI.
465a5e045bSMauro Carvalho Chehab
475a5e045bSMauro Carvalho Chehab
485a5e045bSMauro Carvalho Chehab3. Application Registration and Communication
495a5e045bSMauro Carvalho Chehab=============================================
505a5e045bSMauro Carvalho Chehab
515a5e045bSMauro Carvalho ChehabKernel CAPI forwards registration requests from applications (calls to CAPI
525a5e045bSMauro Carvalho Chehaboperation CAPI_REGISTER) to an appropriate hardware driver by calling its
535a5e045bSMauro Carvalho Chehabregister_appl() callback function. A unique Application ID (ApplID, u16) is
545a5e045bSMauro Carvalho Chehaballocated by Kernel CAPI and passed to register_appl() along with the
555a5e045bSMauro Carvalho Chehabparameter structure provided by the application. This is analogous to the
565a5e045bSMauro Carvalho Chehabopen() operation on regular files or character devices.
575a5e045bSMauro Carvalho Chehab
585a5e045bSMauro Carvalho ChehabAfter a successful return from register_appl(), CAPI messages from the
595a5e045bSMauro Carvalho Chehabapplication may be passed to the driver for the device via calls to the
605a5e045bSMauro Carvalho Chehabsend_message() callback function. Conversely, the driver may call Kernel
615a5e045bSMauro Carvalho ChehabCAPI's capi_ctr_handle_message() function to pass a received CAPI message to
625a5e045bSMauro Carvalho ChehabKernel CAPI for forwarding to an application, specifying its ApplID.
635a5e045bSMauro Carvalho Chehab
645a5e045bSMauro Carvalho ChehabDeregistration requests (CAPI operation CAPI_RELEASE) from applications are
655a5e045bSMauro Carvalho Chehabforwarded as calls to the release_appl() callback function, passing the same
665a5e045bSMauro Carvalho ChehabApplID as with register_appl(). After return from release_appl(), no CAPI
675a5e045bSMauro Carvalho Chehabmessages for that application may be passed to or from the device anymore.
685a5e045bSMauro Carvalho Chehab
695a5e045bSMauro Carvalho Chehab
705a5e045bSMauro Carvalho Chehab4. Data Structures
715a5e045bSMauro Carvalho Chehab==================
725a5e045bSMauro Carvalho Chehab
735a5e045bSMauro Carvalho Chehab4.1 struct capi_driver
745a5e045bSMauro Carvalho Chehab----------------------
755a5e045bSMauro Carvalho Chehab
765a5e045bSMauro Carvalho ChehabThis structure describes a Kernel CAPI driver itself. It is used in the
775a5e045bSMauro Carvalho Chehabregister_capi_driver() and unregister_capi_driver() functions, and contains
785a5e045bSMauro Carvalho Chehabthe following non-private fields, all to be set by the driver before calling
795a5e045bSMauro Carvalho Chehabregister_capi_driver():
805a5e045bSMauro Carvalho Chehab
815a5e045bSMauro Carvalho Chehab``char name[32]``
825a5e045bSMauro Carvalho Chehab	the name of the driver, as a zero-terminated ASCII string
835a5e045bSMauro Carvalho Chehab``char revision[32]``
845a5e045bSMauro Carvalho Chehab	the revision number of the driver, as a zero-terminated ASCII string
855a5e045bSMauro Carvalho Chehab
865a5e045bSMauro Carvalho Chehab4.2 struct capi_ctr
875a5e045bSMauro Carvalho Chehab-------------------
885a5e045bSMauro Carvalho Chehab
895a5e045bSMauro Carvalho ChehabThis structure describes an ISDN device (controller) handled by a Kernel CAPI
905a5e045bSMauro Carvalho Chehabdriver. After registration via the attach_capi_ctr() function it is passed to
915a5e045bSMauro Carvalho Chehaball controller specific lower layer interface and callback functions to
925a5e045bSMauro Carvalho Chehabidentify the controller to operate on.
935a5e045bSMauro Carvalho Chehab
945a5e045bSMauro Carvalho ChehabIt contains the following non-private fields:
955a5e045bSMauro Carvalho Chehab
965a5e045bSMauro Carvalho Chehabto be set by the driver before calling attach_capi_ctr():
975a5e045bSMauro Carvalho Chehab^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
985a5e045bSMauro Carvalho Chehab
995a5e045bSMauro Carvalho Chehab``struct module *owner``
1005a5e045bSMauro Carvalho Chehab	pointer to the driver module owning the device
1015a5e045bSMauro Carvalho Chehab
1025a5e045bSMauro Carvalho Chehab``void *driverdata``
1035a5e045bSMauro Carvalho Chehab	an opaque pointer to driver specific data, not touched by Kernel CAPI
1045a5e045bSMauro Carvalho Chehab
1055a5e045bSMauro Carvalho Chehab``char name[32]``
1065a5e045bSMauro Carvalho Chehab	the name of the controller, as a zero-terminated ASCII string
1075a5e045bSMauro Carvalho Chehab
1085a5e045bSMauro Carvalho Chehab``char *driver_name``
1095a5e045bSMauro Carvalho Chehab	the name of the driver, as a zero-terminated ASCII string
1105a5e045bSMauro Carvalho Chehab
1115a5e045bSMauro Carvalho Chehab``int (*load_firmware)(struct capi_ctr *ctrlr, capiloaddata *ldata)``
1125a5e045bSMauro Carvalho Chehab	(optional) pointer to a callback function for sending firmware and
1135a5e045bSMauro Carvalho Chehab	configuration data to the device
1145a5e045bSMauro Carvalho Chehab
1155a5e045bSMauro Carvalho Chehab	The function may return before the operation has completed.
1165a5e045bSMauro Carvalho Chehab
1175a5e045bSMauro Carvalho Chehab	Completion must be signalled by a call to capi_ctr_ready().
1185a5e045bSMauro Carvalho Chehab
1195a5e045bSMauro Carvalho Chehab	Return value: 0 on success, error code on error
1205a5e045bSMauro Carvalho Chehab	Called in process context.
1215a5e045bSMauro Carvalho Chehab
1225a5e045bSMauro Carvalho Chehab``void (*reset_ctr)(struct capi_ctr *ctrlr)``
1235a5e045bSMauro Carvalho Chehab	(optional) pointer to a callback function for stopping the device,
1245a5e045bSMauro Carvalho Chehab	releasing all registered applications
1255a5e045bSMauro Carvalho Chehab
1265a5e045bSMauro Carvalho Chehab	The function may return before the operation has completed.
1275a5e045bSMauro Carvalho Chehab
1285a5e045bSMauro Carvalho Chehab	Completion must be signalled by a call to capi_ctr_down().
1295a5e045bSMauro Carvalho Chehab
1305a5e045bSMauro Carvalho Chehab	Called in process context.
1315a5e045bSMauro Carvalho Chehab
1325a5e045bSMauro Carvalho Chehab``void (*register_appl)(struct capi_ctr *ctrlr, u16 applid, capi_register_params *rparam)``
1335a5e045bSMauro Carvalho Chehab	pointers to callback function for registration of
1345a5e045bSMauro Carvalho Chehab	applications with the device
1355a5e045bSMauro Carvalho Chehab
1365a5e045bSMauro Carvalho Chehab	Calls to these functions are serialized by Kernel CAPI so that only
1375a5e045bSMauro Carvalho Chehab	one call to any of them is active at any time.
1385a5e045bSMauro Carvalho Chehab
1395a5e045bSMauro Carvalho Chehab``void (*release_appl)(struct capi_ctr *ctrlr, u16 applid)``
1405a5e045bSMauro Carvalho Chehab	pointers to callback functions deregistration of
1415a5e045bSMauro Carvalho Chehab	applications with the device
1425a5e045bSMauro Carvalho Chehab
1435a5e045bSMauro Carvalho Chehab	Calls to these functions are serialized by Kernel CAPI so that only
1445a5e045bSMauro Carvalho Chehab	one call to any of them is active at any time.
1455a5e045bSMauro Carvalho Chehab
1465a5e045bSMauro Carvalho Chehab``u16  (*send_message)(struct capi_ctr *ctrlr, struct sk_buff *skb)``
1475a5e045bSMauro Carvalho Chehab	pointer to a callback function for sending a CAPI message to the
1485a5e045bSMauro Carvalho Chehab	device
1495a5e045bSMauro Carvalho Chehab
1505a5e045bSMauro Carvalho Chehab	Return value: CAPI error code
1515a5e045bSMauro Carvalho Chehab
1525a5e045bSMauro Carvalho Chehab	If the method returns 0 (CAPI_NOERROR) the driver has taken ownership
1535a5e045bSMauro Carvalho Chehab	of the skb and the caller may no longer access it. If it returns a
1545a5e045bSMauro Carvalho Chehab	non-zero (error) value then ownership of the skb returns to the caller
1555a5e045bSMauro Carvalho Chehab	who may reuse or free it.
1565a5e045bSMauro Carvalho Chehab
1575a5e045bSMauro Carvalho Chehab	The return value should only be used to signal problems with respect
1585a5e045bSMauro Carvalho Chehab	to accepting or queueing the message. Errors occurring during the
1595a5e045bSMauro Carvalho Chehab	actual processing of the message should be signaled with an
1605a5e045bSMauro Carvalho Chehab	appropriate reply message.
1615a5e045bSMauro Carvalho Chehab
1625a5e045bSMauro Carvalho Chehab	May be called in process or interrupt context.
1635a5e045bSMauro Carvalho Chehab
1645a5e045bSMauro Carvalho Chehab	Calls to this function are not serialized by Kernel CAPI, ie. it must
1655a5e045bSMauro Carvalho Chehab	be prepared to be re-entered.
1665a5e045bSMauro Carvalho Chehab
1675a5e045bSMauro Carvalho Chehab``char *(*procinfo)(struct capi_ctr *ctrlr)``
1685a5e045bSMauro Carvalho Chehab	pointer to a callback function returning the entry for the device in
1695a5e045bSMauro Carvalho Chehab	the CAPI controller info table, /proc/capi/controller
1705a5e045bSMauro Carvalho Chehab
1715a5e045bSMauro Carvalho ChehabNote:
1725a5e045bSMauro Carvalho Chehab  Callback functions except send_message() are never called in interrupt
1735a5e045bSMauro Carvalho Chehab  context.
1745a5e045bSMauro Carvalho Chehab
1755a5e045bSMauro Carvalho Chehabto be filled in before calling capi_ctr_ready():
1765a5e045bSMauro Carvalho Chehab^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1775a5e045bSMauro Carvalho Chehab
1785a5e045bSMauro Carvalho Chehab``u8 manu[CAPI_MANUFACTURER_LEN]``
1795a5e045bSMauro Carvalho Chehab	value to return for CAPI_GET_MANUFACTURER
1805a5e045bSMauro Carvalho Chehab
1815a5e045bSMauro Carvalho Chehab``capi_version version``
1825a5e045bSMauro Carvalho Chehab	value to return for CAPI_GET_VERSION
1835a5e045bSMauro Carvalho Chehab
1845a5e045bSMauro Carvalho Chehab``capi_profile profile``
1855a5e045bSMauro Carvalho Chehab	value to return for CAPI_GET_PROFILE
1865a5e045bSMauro Carvalho Chehab
1875a5e045bSMauro Carvalho Chehab``u8 serial[CAPI_SERIAL_LEN]``
1885a5e045bSMauro Carvalho Chehab	value to return for CAPI_GET_SERIAL
1895a5e045bSMauro Carvalho Chehab
1905a5e045bSMauro Carvalho Chehab
1915a5e045bSMauro Carvalho Chehab4.3 SKBs
1925a5e045bSMauro Carvalho Chehab--------
1935a5e045bSMauro Carvalho Chehab
1945a5e045bSMauro Carvalho ChehabCAPI messages are passed between Kernel CAPI and the driver via send_message()
1955a5e045bSMauro Carvalho Chehaband capi_ctr_handle_message(), stored in the data portion of a socket buffer
1965a5e045bSMauro Carvalho Chehab(skb).  Each skb contains a single CAPI message coded according to the CAPI 2.0
1975a5e045bSMauro Carvalho Chehabstandard.
1985a5e045bSMauro Carvalho Chehab
1995a5e045bSMauro Carvalho ChehabFor the data transfer messages, DATA_B3_REQ and DATA_B3_IND, the actual
2005a5e045bSMauro Carvalho Chehabpayload data immediately follows the CAPI message itself within the same skb.
2015a5e045bSMauro Carvalho ChehabThe Data and Data64 parameters are not used for processing. The Data64
2025a5e045bSMauro Carvalho Chehabparameter may be omitted by setting the length field of the CAPI message to 22
2035a5e045bSMauro Carvalho Chehabinstead of 30.
2045a5e045bSMauro Carvalho Chehab
2055a5e045bSMauro Carvalho Chehab
2065a5e045bSMauro Carvalho Chehab4.4 The _cmsg Structure
2075a5e045bSMauro Carvalho Chehab-----------------------
2085a5e045bSMauro Carvalho Chehab
2095a5e045bSMauro Carvalho Chehab(declared in <linux/isdn/capiutil.h>)
2105a5e045bSMauro Carvalho Chehab
2115a5e045bSMauro Carvalho ChehabThe _cmsg structure stores the contents of a CAPI 2.0 message in an easily
2125a5e045bSMauro Carvalho Chehabaccessible form. It contains members for all possible CAPI 2.0 parameters,
2135a5e045bSMauro Carvalho Chehabincluding subparameters of the Additional Info and B Protocol structured
2145a5e045bSMauro Carvalho Chehabparameters, with the following exceptions:
2155a5e045bSMauro Carvalho Chehab
2165a5e045bSMauro Carvalho Chehab* second Calling party number (CONNECT_IND)
2175a5e045bSMauro Carvalho Chehab
2185a5e045bSMauro Carvalho Chehab* Data64 (DATA_B3_REQ and DATA_B3_IND)
2195a5e045bSMauro Carvalho Chehab
2205a5e045bSMauro Carvalho Chehab* Sending complete (subparameter of Additional Info, CONNECT_REQ and INFO_REQ)
2215a5e045bSMauro Carvalho Chehab
2225a5e045bSMauro Carvalho Chehab* Global Configuration (subparameter of B Protocol, CONNECT_REQ, CONNECT_RESP
2235a5e045bSMauro Carvalho Chehab  and SELECT_B_PROTOCOL_REQ)
2245a5e045bSMauro Carvalho Chehab
2255a5e045bSMauro Carvalho ChehabOnly those parameters appearing in the message type currently being processed
2265a5e045bSMauro Carvalho Chehabare actually used. Unused members should be set to zero.
2275a5e045bSMauro Carvalho Chehab
2285a5e045bSMauro Carvalho ChehabMembers are named after the CAPI 2.0 standard names of the parameters they
2295a5e045bSMauro Carvalho Chehabrepresent. See <linux/isdn/capiutil.h> for the exact spelling. Member data
2305a5e045bSMauro Carvalho Chehabtypes are:
2315a5e045bSMauro Carvalho Chehab
2325a5e045bSMauro Carvalho Chehab=========== =================================================================
2335a5e045bSMauro Carvalho Chehabu8          for CAPI parameters of type 'byte'
2345a5e045bSMauro Carvalho Chehab
2355a5e045bSMauro Carvalho Chehabu16         for CAPI parameters of type 'word'
2365a5e045bSMauro Carvalho Chehab
2375a5e045bSMauro Carvalho Chehabu32         for CAPI parameters of type 'dword'
2385a5e045bSMauro Carvalho Chehab
2395a5e045bSMauro Carvalho Chehab_cstruct    for CAPI parameters of type 'struct'
2405a5e045bSMauro Carvalho Chehab	    The member is a pointer to a buffer containing the parameter in
2415a5e045bSMauro Carvalho Chehab	    CAPI encoding (length + content). It may also be NULL, which will
2425a5e045bSMauro Carvalho Chehab	    be taken to represent an empty (zero length) parameter.
2435a5e045bSMauro Carvalho Chehab	    Subparameters are stored in encoded form within the content part.
2445a5e045bSMauro Carvalho Chehab
2455a5e045bSMauro Carvalho Chehab_cmstruct   alternative representation for CAPI parameters of type 'struct'
2465a5e045bSMauro Carvalho Chehab	    (used only for the 'Additional Info' and 'B Protocol' parameters)
2475a5e045bSMauro Carvalho Chehab	    The representation is a single byte containing one of the values:
2485a5e045bSMauro Carvalho Chehab	    CAPI_DEFAULT: The parameter is empty/absent.
2495a5e045bSMauro Carvalho Chehab	    CAPI_COMPOSE: The parameter is present.
2505a5e045bSMauro Carvalho Chehab	    Subparameter values are stored individually in the corresponding
2515a5e045bSMauro Carvalho Chehab	    _cmsg structure members.
2525a5e045bSMauro Carvalho Chehab=========== =================================================================
2535a5e045bSMauro Carvalho Chehab
2545a5e045bSMauro Carvalho Chehab
2555a5e045bSMauro Carvalho Chehab5. Lower Layer Interface Functions
2565a5e045bSMauro Carvalho Chehab==================================
2575a5e045bSMauro Carvalho Chehab
2585a5e045bSMauro Carvalho Chehab::
2595a5e045bSMauro Carvalho Chehab
2605a5e045bSMauro Carvalho Chehab  int attach_capi_ctr(struct capi_ctr *ctrlr)
2615a5e045bSMauro Carvalho Chehab  int detach_capi_ctr(struct capi_ctr *ctrlr)
2625a5e045bSMauro Carvalho Chehab
2635a5e045bSMauro Carvalho Chehabregister/unregister a device (controller) with Kernel CAPI
2645a5e045bSMauro Carvalho Chehab
2655a5e045bSMauro Carvalho Chehab::
2665a5e045bSMauro Carvalho Chehab
2675a5e045bSMauro Carvalho Chehab  void capi_ctr_ready(struct capi_ctr *ctrlr)
2685a5e045bSMauro Carvalho Chehab  void capi_ctr_down(struct capi_ctr *ctrlr)
2695a5e045bSMauro Carvalho Chehab
2705a5e045bSMauro Carvalho Chehabsignal controller ready/not ready
2715a5e045bSMauro Carvalho Chehab
2725a5e045bSMauro Carvalho Chehab::
2735a5e045bSMauro Carvalho Chehab
2745a5e045bSMauro Carvalho Chehab  void capi_ctr_handle_message(struct capi_ctr * ctrlr, u16 applid,
2755a5e045bSMauro Carvalho Chehab			       struct sk_buff *skb)
2765a5e045bSMauro Carvalho Chehab
2775a5e045bSMauro Carvalho Chehabpass a received CAPI message to Kernel CAPI
2785a5e045bSMauro Carvalho Chehabfor forwarding to the specified application
2795a5e045bSMauro Carvalho Chehab
2805a5e045bSMauro Carvalho Chehab
2815a5e045bSMauro Carvalho Chehab6. Helper Functions and Macros
2825a5e045bSMauro Carvalho Chehab==============================
2835a5e045bSMauro Carvalho Chehab
2845a5e045bSMauro Carvalho ChehabMacros to extract/set element values from/in a CAPI message header
2855a5e045bSMauro Carvalho Chehab(from <linux/isdn/capiutil.h>):
2865a5e045bSMauro Carvalho Chehab
2875a5e045bSMauro Carvalho Chehab======================  =============================   ====================
2885a5e045bSMauro Carvalho ChehabGet Macro		Set Macro			Element (Type)
2895a5e045bSMauro Carvalho Chehab======================  =============================   ====================
2905a5e045bSMauro Carvalho ChehabCAPIMSG_LEN(m)		CAPIMSG_SETLEN(m, len)		Total Length (u16)
2915a5e045bSMauro Carvalho ChehabCAPIMSG_APPID(m)	CAPIMSG_SETAPPID(m, applid)	ApplID (u16)
2925a5e045bSMauro Carvalho ChehabCAPIMSG_COMMAND(m)	CAPIMSG_SETCOMMAND(m,cmd)	Command (u8)
2935a5e045bSMauro Carvalho ChehabCAPIMSG_SUBCOMMAND(m)	CAPIMSG_SETSUBCOMMAND(m, cmd)	Subcommand (u8)
2945a5e045bSMauro Carvalho ChehabCAPIMSG_CMD(m)		-				Command*256
2955a5e045bSMauro Carvalho Chehab							+ Subcommand (u16)
2965a5e045bSMauro Carvalho ChehabCAPIMSG_MSGID(m)	CAPIMSG_SETMSGID(m, msgid)	Message Number (u16)
2975a5e045bSMauro Carvalho Chehab
2985a5e045bSMauro Carvalho ChehabCAPIMSG_CONTROL(m)	CAPIMSG_SETCONTROL(m, contr)	Controller/PLCI/NCCI
2995a5e045bSMauro Carvalho Chehab							(u32)
3005a5e045bSMauro Carvalho ChehabCAPIMSG_DATALEN(m)	CAPIMSG_SETDATALEN(m, len)	Data Length (u16)
3015a5e045bSMauro Carvalho Chehab======================  =============================   ====================
3025a5e045bSMauro Carvalho Chehab
3035a5e045bSMauro Carvalho Chehab
3045a5e045bSMauro Carvalho ChehabLibrary functions for working with _cmsg structures
3055a5e045bSMauro Carvalho Chehab(from <linux/isdn/capiutil.h>):
3065a5e045bSMauro Carvalho Chehab
3075a5e045bSMauro Carvalho Chehab``char *capi_cmd2str(u8 Command, u8 Subcommand)``
3085a5e045bSMauro Carvalho Chehab	Returns the CAPI 2.0 message name corresponding to the given command
3095a5e045bSMauro Carvalho Chehab	and subcommand values, as a static ASCII string. The return value may
3105a5e045bSMauro Carvalho Chehab	be NULL if the command/subcommand is not one of those defined in the
3115a5e045bSMauro Carvalho Chehab	CAPI 2.0 standard.
3125a5e045bSMauro Carvalho Chehab
3135a5e045bSMauro Carvalho Chehab
3145a5e045bSMauro Carvalho Chehab7. Debugging
3155a5e045bSMauro Carvalho Chehab============
3165a5e045bSMauro Carvalho Chehab
3175a5e045bSMauro Carvalho ChehabThe module kernelcapi has a module parameter showcapimsgs controlling some
3185a5e045bSMauro Carvalho Chehabdebugging output produced by the module. It can only be set when the module is
3195a5e045bSMauro Carvalho Chehabloaded, via a parameter "showcapimsgs=<n>" to the modprobe command, either on
3205a5e045bSMauro Carvalho Chehabthe command line or in the configuration file.
3215a5e045bSMauro Carvalho Chehab
3225a5e045bSMauro Carvalho ChehabIf the lowest bit of showcapimsgs is set, kernelcapi logs controller and
3235a5e045bSMauro Carvalho Chehabapplication up and down events.
3245a5e045bSMauro Carvalho Chehab
3255a5e045bSMauro Carvalho ChehabIn addition, every registered CAPI controller has an associated traceflag
326*d12f9ad0SRandy Dunlapparameter controlling how CAPI messages sent from and to the controller are
3275a5e045bSMauro Carvalho Chehablogged. The traceflag parameter is initialized with the value of the
3285a5e045bSMauro Carvalho Chehabshowcapimsgs parameter when the controller is registered, but can later be
3295a5e045bSMauro Carvalho Chehabchanged via the MANUFACTURER_REQ command KCAPI_CMD_TRACE.
3305a5e045bSMauro Carvalho Chehab
3315a5e045bSMauro Carvalho ChehabIf the value of traceflag is non-zero, CAPI messages are logged.
3325a5e045bSMauro Carvalho ChehabDATA_B3 messages are only logged if the value of traceflag is > 2.
3335a5e045bSMauro Carvalho Chehab
3345a5e045bSMauro Carvalho ChehabIf the lowest bit of traceflag is set, only the command/subcommand and message
3355a5e045bSMauro Carvalho Chehablength are logged. Otherwise, kernelcapi logs a readable representation of
3365a5e045bSMauro Carvalho Chehabthe entire message.
337