7 #define pr_fmt(fmt) KBUILD_MODNAME ":%s(): " fmt, __func__
9 #include <linux/stddef.h>
11 #include <linux/slab.h>
17 #define container_obj(layr) container_of(layr, struct cfctrl, serv.layer)
18 #define UTILITY_NAME_LENGTH 16
19 #define CFPKT_CTRL_PKT_LEN 20
30 static int cfctrl_recv(
struct cflayer *layr,
struct cfpkt *pkt);
43 memset(&dev_info, 0,
sizeof(dev_info));
48 this->
serv.layer.receive = cfctrl_recv;
50 this->
serv.layer.ctrlcmd = cfctrl_ctrlcmd;
56 INIT_LIST_HEAD(&this->
list);
57 return &this->
serv.layer;
93 p1->
u.
rfm.connid == p2->
u.
rfm.connid &&
129 static void cfctrl_insert_req(
struct cfctrl *
ctrl,
148 if (cfctrl_req_eq(req, p)) {
150 pr_warn(
"Requests are not received in order\n");
183 pr_debug(
"not able to send enum request\n");
192 cfctrl->
serv.dev_info.id = physlinkid;
209 char utility_name[16];
214 pr_debug(
"not able to send linkup request\n");
220 pr_err(
"Duplicate connect request for same client\n");
260 memset(utility_name, 0,
sizeof(utility_name));
270 pr_warn(
"Request setup of bad link type = %d\n",
280 cfctrl_insert_req(cfctrl, req);
297 pr_err(
"Could not remove request (%d)", count);
312 pr_debug(
"not able to send link-down request\n");
349 static int cfctrl_recv(
struct cflayer *layer,
struct cfpkt *pkt)
367 if (handle_loop(cfctrl, cmd, pkt) != 0)
384 memset(&linkparam, 0,
sizeof(linkparam));
389 linkparam.linktype = serv;
392 linkparam.chtype = servtype;
395 physlinkid = tmp & 0x07;
398 linkparam.priority =
prio;
399 linkparam.phyid = physlinkid;
401 linkparam.endpoint = endpoint & 0x03;
413 linkparam.u.video.connid =
tmp;
422 linkparam.u.datagram.connid =
435 linkparam.u.rfm.connid =
437 cp = (
u8 *) linkparam.u.rfm.volume;
457 linkparam.u.utility.fifosize_kb =
461 linkparam.u.utility.fifosize_bufs =
464 cp = (
u8 *) linkparam.u.utility.name;
475 linkparam.u.utility.paramlen = len;
477 cp = linkparam.u.utility.params;
492 pr_warn(
"Request setup, invalid type (%d)\n",
498 rsp.param = linkparam;
500 req = cfctrl_remove_req(cfctrl, &
rsp);
504 pr_err(
"Invalid O/E bit or parse error "
505 "on CAIF control channel\n");
506 cfctrl->
res.reject_rsp(cfctrl->
serv.layer.up,
511 cfctrl->
res.linksetup_rsp(cfctrl->
serv.
515 client_layer :
NULL);
526 cfctrl->
res.linkdestroy_rsp(cfctrl->
serv.layer.up, linkid);
529 pr_err(
"Frame Error Indication received\n");
530 cfctrl->
res.linkerror_ind();
533 cfctrl->
res.enum_rsp();
536 cfctrl->
res.sleep_rsp();
539 cfctrl->
res.wake_rsp();
542 cfctrl->
res.restart_rsp();
545 cfctrl->
res.radioset_rsp();
548 pr_err(
"Unrecognized Control Frame\n");
566 if (!list_empty(&this->
list))
567 pr_debug(
"Received flow off in control layer\n");
574 spin_lock_bh(&this->info_list_lock);
576 if (p->
param.phyid == phyid) {
584 spin_unlock_bh(&this->info_list_lock);
593 static int handle_loop(
struct cfctrl *ctrl,
int cmd,
struct cfpkt *pkt)
595 static int last_linkid;
597 u8 linkid, linktype,
tmp;
602 for (linkid = last_linkid + 1; linkid < 254; linkid++)
607 for (linkid = last_linkid - 1; linkid > 1; linkid--)
619 last_linkid = linkid;