本文整理汇总了C++中VDBG函数的典型用法代码示例。如果您正苦于以下问题:C++ VDBG函数的具体用法?C++ VDBG怎么用?C++ VDBG使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了VDBG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eth_stop
static int eth_stop(struct net_device *net)
{
struct eth_dev *dev = netdev_priv(net);
unsigned long flags;
VDBG(dev, "%s\n", __func__);
netif_stop_queue(net);
DBG(dev, "stop stats: rx/tx %ld/%ld, errs %ld/%ld\n",
dev->net->stats.rx_packets, dev->net->stats.tx_packets,
dev->net->stats.rx_errors, dev->net->stats.tx_errors
);
/* ensure there are no more active requests */
spin_lock_irqsave(&dev->lock, flags);
if (dev->port_usb) {
struct gether *link = dev->port_usb;
if (link->close)
link->close(link);
/* NOTE: we have no abort-queue primitive we could use
* to cancel all pending I/O. Instead, we disable then
* reenable the endpoints ... this idiom may leave toggle
* wrong, but that's a self-correcting error.
*
* REVISIT: we *COULD* just let the transfers complete at
* their own pace; the network stack can handle old packets.
* For the moment we leave this here, since it works.
*/
usb_ep_disable(link->in_ep);
usb_ep_disable(link->out_ep);
if (netif_carrier_ok(net)) {
DBG(dev, "host still using in/out endpoints\n");
usb_ep_enable(link->in_ep, link->in);
usb_ep_enable(link->out_ep, link->out);
}
}
spin_unlock_irqrestore(&dev->lock, flags);
return 0;
}
示例2: guard
void
MulticastTransport::passive_connection(MulticastPeer local_peer, MulticastPeer remote_peer)
{
GuardThreadType guard(this->connections_lock_);
VDBG_LVL((LM_DEBUG, "(%P|%t) MulticastTransport[%C]::passive_connection "
"from remote peer 0x%x to local peer 0x%x\n",
this->config_i_->name().c_str(), remote_peer, local_peer), 2);
const Peers peers(remote_peer, local_peer);
const PendConnMap::iterator pend = this->pending_connections_.find(peers);
if (pend != pending_connections_.end()) {
Links::const_iterator server_link = this->server_links_.find(local_peer);
DataLink_rch link;
if (server_link != this->server_links_.end()) {
link = static_rchandle_cast<DataLink>(server_link->second);
}
VDBG((LM_DEBUG, "(%P|%t) MulticastTransport::passive_connection completing\n"));
PendConnMap::iterator updated_pend = pend;
do {
TransportClient* pend_client = updated_pend->second.front().first;
RepoId remote_repo = updated_pend->second.front().second;
guard.release();
pend_client->use_datalink(remote_repo, link);
guard.acquire();
} while ((updated_pend = pending_connections_.find(peers)) != pending_connections_.end());
}
//if connection was pending, calls to use_datalink finalized the connection
//if it was not previously pending, accept_datalink() will finalize connection
this->connections_.insert(peers);
}
示例3: proc_status_read
int proc_status_read(char *buffer, char **start, off_t offset, int count,
int *eof, void *user_data)
{
struct psfreedom_device *dev = user_data;
unsigned int len;
unsigned long flags;
spin_lock_irqsave (&dev->lock, flags);
/* This file is meant to be read in a loop, so don't spam dmesg with an INFO
message when it gets read */
VDBG (dev, "proc_status_read (/proc/%s/%s) called. count %d\n",
PROC_DIR_NAME, PROC_STATUS_NAME, count);
*eof = 1;
/* fill the buffer, return the buffer size */
len = sprintf (buffer + offset, "%s\n", STATUS_STR (dev->status));
spin_unlock_irqrestore (&dev->lock, flags);
return len;
}
示例4: calibrate_bitpool
void calibrate_bitpool( struct bluetooth_data *data, int increase)
{
VDBG(" Bitpool Calibrationg bitpool %d",data->sbc.bitpool);
VDBG(" Bitpool Calibrationg freq %d",data->sbc.frequency);
VDBG(" Bitpool Calibrationg mode %d",data->sbc.mode);
VDBG(" Bitpool Calibrationg max_bitpool %d",data->sbc_capabilities.max_bitpool);
VDBG(" Bitpool Calibrationg min_bitpool %d",data->sbc_capabilities.min_bitpool);
VDBG(" origin bitpool %d",data->bitpool);
// VDBG(" Bitpool Calibrationg to %d",data->sbc.bitpool);
// VDBG(" Bitpool Calibrationg to %d",data->sbc.bitpool);
if( increase ){
data->sbc.bitpool=data->sbc_capabilities.max_bitpool;
DBG(" Bitpool increased to %d",data->sbc.bitpool);
} else { // if we are decreasing bitpool, using middle quality values
if( data->sbc.bitpool != data->sbc_capabilities.max_bitpool ) return;
skip_avdtp_flow_check=1;
if(data->sbc_capabilities.max_bitpool <= 35 ){
if ((data->sbc.mode == SBC_MODE_JOINT_STEREO) ||
(data->sbc.mode == SBC_MODE_STEREO )){
switch( data->sbc.frequency ){
case BT_SBC_SAMPLING_FREQ_44100:
data->sbc.bitpool = MAX(19,data->sbc_capabilities.min_bitpool);
break;
case BT_SBC_SAMPLING_FREQ_48000:
data->sbc.bitpool = MAX(18, data->sbc_capabilities.min_bitpool);
break;
}
} else { // for other modes
switch ( data->sbc.frequency) {
case BT_SBC_SAMPLING_FREQ_44100:
data->sbc.bitpool = MAX(19,data->sbc_capabilities.min_bitpool);
break;
case BT_SBC_SAMPLING_FREQ_48000:
data->sbc.bitpool = MAX(18, data->sbc_capabilities.min_bitpool);
break;
}
}
}else{
data->sbc.bitpool=data->sbc_capabilities.max_bitpool-20;
}
DBG(" Bitpool decreased to %d",data->sbc.bitpool);
}
}
示例5: VDBG
void
MulticastTransport::stop_accepting_or_connecting(TransportClient* client,
const RepoId& remote_id)
{
VDBG((LM_DEBUG, "(%P|%t) MulticastTransport::stop_accepting_or_connecting\n"));
GuardThreadType guard(this->connections_lock_);
for (PendConnMap::iterator it = this->pending_connections_.begin();
it != this->pending_connections_.end(); ++it) {
for (size_t i = 0; i < it->second.size(); ++i) {
if (it->second[i].first == client && it->second[i].second == remote_id) {
it->second.erase(it->second.begin() + i);
break;
}
}
if (it->second.empty()) {
this->pending_connections_.erase(it);
return;
}
}
}
示例6: run
/**
* Run a script. argv[2] is already NULL.
*/
static int run(char *argv[3], struct in_addr *ip)
{
int status;
char *addr = addr; /* for gcc */
const char *fmt = "%s %s %s" + 3;
VDBG("%s run %s %s\n", intf, argv[0], argv[1]);
if (ip) {
addr = inet_ntoa(*ip);
setenv("ip", addr, 1);
fmt -= 3;
}
bb_info_msg(fmt, argv[1], intf, addr);
status = wait4pid(spawn(argv));
if (status < 0) {
bb_perror_msg("%s %s %s" + 3, argv[1], intf);
return -errno;
}
if (status != 0)
bb_error_msg("script %s %s failed, exitcode=%d", argv[0], argv[1], status);
return status;
}
示例7: tx_complete
static void tx_complete(struct usb_ep *ep, struct usb_request *req)
{
struct printer_dev *dev = ep->driver_data;
switch (req->status) {
default:
VDBG(dev, "tx err %d\n", req->status);
case -ECONNRESET:
case -ESHUTDOWN:
break;
case 0:
break;
}
spin_lock(&dev->lock);
list_del_init(&req->list);
list_add(&req->list, &dev->tx_reqs);
wake_up_interruptible(&dev->tx_wait);
if (likely(list_empty(&dev->tx_reqs_active)))
wake_up_interruptible(&dev->tx_flush_wait);
spin_unlock(&dev->lock);
}
示例8: otg_set_state
/* Called when entering a state */
int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state)
{
state_changed = 1;
if (fsm->transceiver->state == new_state)
return 0;
VDBG("chg state to %s", state_string(new_state));
otg_leave_state(fsm, fsm->transceiver->state);
switch (new_state) {
case OTG_STATE_B_IDLE:
otg_drv_vbus(fsm, 0);
otg_chrg_vbus(fsm, 0);
otg_loc_conn(fsm, 0);
otg_loc_sof(fsm, 0);
otg_set_protocol(fsm, PROTO_UNDEF);
otg_add_timer(fsm, b_se0_srp_tmr);
break;
case OTG_STATE_B_SRP_INIT:
otg_start_pulse(fsm);
otg_loc_sof(fsm, 0);
otg_set_protocol(fsm, PROTO_UNDEF);
otg_add_timer(fsm, b_srp_fail_tmr);
break;
case OTG_STATE_B_PERIPHERAL:
otg_chrg_vbus(fsm, 0);
otg_loc_conn(fsm, 1);
otg_loc_sof(fsm, 0);
otg_set_protocol(fsm, PROTO_GADGET);
break;
case OTG_STATE_B_WAIT_ACON:
otg_chrg_vbus(fsm, 0);
otg_loc_conn(fsm, 0);
otg_loc_sof(fsm, 0);
otg_set_protocol(fsm, PROTO_HOST);
otg_add_timer(fsm, b_ase0_brst_tmr);
fsm->a_bus_suspend = 0;
break;
case OTG_STATE_B_HOST:
otg_chrg_vbus(fsm, 0);
otg_loc_conn(fsm, 0);
otg_loc_sof(fsm, 1);
otg_set_protocol(fsm, PROTO_HOST);
usb_bus_start_enum(fsm->transceiver->host,
fsm->transceiver->host->otg_port);
break;
case OTG_STATE_A_IDLE:
otg_drv_vbus(fsm, 0);
otg_chrg_vbus(fsm, 0);
otg_loc_conn(fsm, 0);
otg_loc_sof(fsm, 0);
otg_set_protocol(fsm, PROTO_HOST);
break;
case OTG_STATE_A_WAIT_VRISE:
otg_drv_vbus(fsm, 1);
otg_loc_conn(fsm, 0);
otg_loc_sof(fsm, 0);
otg_set_protocol(fsm, PROTO_HOST);
otg_add_timer(fsm, a_wait_vrise_tmr);
break;
case OTG_STATE_A_WAIT_BCON:
otg_drv_vbus(fsm, 1);
otg_loc_conn(fsm, 0);
otg_loc_sof(fsm, 0);
otg_set_protocol(fsm, PROTO_HOST);
otg_add_timer(fsm, a_wait_bcon_tmr);
break;
case OTG_STATE_A_HOST:
otg_drv_vbus(fsm, 1);
otg_loc_conn(fsm, 0);
otg_loc_sof(fsm, 1);
otg_set_protocol(fsm, PROTO_HOST);
/* When HNP is triggered while a_bus_req = 0, a_host will
* suspend too fast to complete a_set_b_hnp_en
*/
if (!fsm->a_bus_req || fsm->a_suspend_req)
otg_add_timer(fsm, a_wait_enum_tmr);
break;
case OTG_STATE_A_SUSPEND:
otg_drv_vbus(fsm, 1);
otg_loc_conn(fsm, 0);
otg_loc_sof(fsm, 0);
otg_set_protocol(fsm, PROTO_HOST);
otg_add_timer(fsm, a_aidl_bdis_tmr);
break;
case OTG_STATE_A_PERIPHERAL:
otg_loc_conn(fsm, 1);
otg_loc_sof(fsm, 0);
otg_set_protocol(fsm, PROTO_GADGET);
otg_drv_vbus(fsm, 1);
break;
case OTG_STATE_A_WAIT_VFALL:
otg_drv_vbus(fsm, 0);
otg_loc_conn(fsm, 0);
otg_loc_sof(fsm, 0);
otg_set_protocol(fsm, PROTO_HOST);
break;
//.........这里部分代码省略.........
示例9: devices_bind
static int __init devices_bind(struct usb_gadget *gadget,
struct psfreedom_device *dev)
{
struct usb_ep *out_ep;
struct usb_ep *in_ep;
gadget_for_each_ep (out_ep, gadget) {
if (0 == strcmp (out_ep->name,
psfreedom_get_endpoint_name (&jig_out_endpoint_desc)))
break;
}
if (!out_ep) {
ERROR (dev, "%s: can't find %s on %s\n",
psfreedom_get_endpoint_name (&jig_out_endpoint_desc),
shortname, gadget->name);
return -ENODEV;
}
out_ep->driver_data = out_ep; /* claim */
gadget_for_each_ep (in_ep, gadget) {
if (0 == strcmp (in_ep->name,
psfreedom_get_endpoint_name (&jig_in_endpoint_desc)))
break;
}
if (!in_ep) {
ERROR (dev, "%s: can't find %s on %s\n",
psfreedom_get_endpoint_name (&jig_in_endpoint_desc),
shortname, gadget->name);
return -ENODEV;
}
in_ep->driver_data = in_ep; /* claim */
/* ok, we made sense of the hardware ... */
dev->in_ep = in_ep;
dev->out_ep = out_ep;
/* If the machine specific code changed our descriptors,
change the ones we'll send too */
memcpy (port5_config_desc + USB_DT_CONFIG_SIZE + USB_DT_INTERFACE_SIZE,
&jig_out_endpoint_desc,
USB_DT_ENDPOINT_SIZE);
memcpy (port5_config_desc + USB_DT_CONFIG_SIZE + \
USB_DT_INTERFACE_SIZE + USB_DT_ENDPOINT_SIZE,
&jig_in_endpoint_desc,
USB_DT_ENDPOINT_SIZE);
INFO(dev, "using %s, EP IN %s (0x%X)\n", gadget->name, in_ep->name,
jig_in_endpoint_desc.bEndpointAddress);
INFO(dev, "using %s, EP OUT %s (0x%X)\n", gadget->name, out_ep->name,
jig_out_endpoint_desc.bEndpointAddress);
/* the max packet size of all the devices must be the same as the ep0 max
packet size, otherwise it won't work */
((struct usb_device_descriptor *)port1_device_desc)->bMaxPacketSize0 = \
((struct usb_device_descriptor *)port2_device_desc)->bMaxPacketSize0 = \
((struct usb_device_descriptor *)port3_device_desc)->bMaxPacketSize0 = \
((struct usb_device_descriptor *)port4_device_desc)->bMaxPacketSize0 = \
((struct usb_device_descriptor *)port5_device_desc)->bMaxPacketSize0 = \
((struct usb_device_descriptor *)port6_device_desc)->bMaxPacketSize0 = \
gadget->ep0->maxpacket;
VDBG(dev, "devices_bind finished ok\n");
return 0;
}
示例10: tx_complete
static void tx_complete(struct usb_ep *ep, struct usb_request *req)
{
struct sk_buff *skb = req->context;
struct eth_dev *dev = ep->driver_data;
struct net_device *net = dev->net;
struct usb_request *new_req;
struct usb_ep *in;
int length;
int retval;
switch (req->status) {
default:
dev->net->stats.tx_errors++;
VDBG(dev, "tx err %d\n", req->status);
/* FALLTHROUGH */
case -ECONNRESET: /* unlink */
case -ESHUTDOWN: /* disconnect etc */
break;
case 0:
if (!req->zero)
dev->net->stats.tx_bytes += req->length-1;
else
dev->net->stats.tx_bytes += req->length;
}
dev->net->stats.tx_packets++;
spin_lock(&dev->req_lock);
list_add_tail(&req->list, &dev->tx_reqs);
if (dev->port_usb->multi_pkt_xfer) {
dev->no_tx_req_used--;
req->length = 0;
in = dev->port_usb->in_ep;
if (!list_empty(&dev->tx_reqs)) {
new_req = container_of(dev->tx_reqs.next,
struct usb_request, list);
list_del(&new_req->list);
spin_unlock(&dev->req_lock);
if (new_req->length > 0) {
length = new_req->length;
/* NCM requires no zlp if transfer is
* dwNtbInMaxSize */
if (dev->port_usb->is_fixed &&
length == dev->port_usb->fixed_in_len &&
(length % in->maxpacket) == 0)
new_req->zero = 0;
else
new_req->zero = 1;
/* use zlp framing on tx for strict CDC-Ether
* conformance, though any robust network rx
* path ignores extra padding. and some hardware
* doesn't like to write zlps.
*/
if (new_req->zero && !dev->zlp &&
(length % in->maxpacket) == 0) {
new_req->zero = 0;
length++;
}
new_req->length = length;
retval = usb_ep_queue(in, new_req, GFP_ATOMIC);
switch (retval) {
default:
DBG(dev, "tx queue err %d\n", retval);
break;
case 0:
spin_lock(&dev->req_lock);
dev->no_tx_req_used++;
spin_unlock(&dev->req_lock);
net->trans_start = jiffies;
}
} else {
spin_lock(&dev->req_lock);
list_add(&new_req->list, &dev->tx_reqs);
spin_unlock(&dev->req_lock);
}
} else {
示例11: zcip_main
//.........这里部分代码省略.........
// - arp probes to see if another host uses it
// - arp announcements that we're claiming it
// - use it
// - defend it, within limits
// exit if:
// - address is successfully obtained and -q was given:
// run "<script> config", then exit with exitcode 0
// - poll error (when does this happen?)
// - read error (when does this happen?)
// - sendto error (in arp()) (when does this happen?)
// - revents & POLLERR (link down). run "<script> deconfig" first
state = PROBE;
while (1) {
struct pollfd fds[1];
unsigned deadline_us;
struct arp_packet p;
int source_ip_conflict;
int target_ip_conflict;
fds[0].fd = sock_fd;
fds[0].events = POLLIN;
fds[0].revents = 0;
// poll, being ready to adjust current timeout
if (!timeout_ms) {
timeout_ms = random_delay_ms(PROBE_WAIT);
// FIXME setsockopt(sock_fd, SO_ATTACH_FILTER, ...) to
// make the kernel filter out all packets except
// ones we'd care about.
}
// set deadline_us to the point in time when we timeout
deadline_us = MONOTONIC_US() + timeout_ms * 1000;
VDBG("...wait %d %s nprobes=%u, nclaims=%u\n",
timeout_ms, argv_intf, nprobes, nclaims);
switch (safe_poll(fds, 1, timeout_ms)) {
default:
//bb_perror_msg("poll"); - done in safe_poll
cleanup(EXIT_FAILURE);
// timeout
case 0:
VDBG("state = %d\n", state);
switch (state) {
case PROBE:
// timeouts in the PROBE state mean no conflicting ARP packets
// have been received, so we can progress through the states
if (nprobes < PROBE_NUM) {
nprobes++;
VDBG("probe/%u %[email protected]%s\n",
nprobes, argv_intf, inet_ntoa(ip));
arp(/* ARPOP_REQUEST, */
/* ð_addr, */ null_ip,
&null_addr, ip);
timeout_ms = PROBE_MIN * 1000;
timeout_ms += random_delay_ms(PROBE_MAX - PROBE_MIN);
}
else {
// Switch to announce state.
state = ANNOUNCE;
nclaims = 0;
VDBG("announce/%u %[email protected]%s\n",
nclaims, argv_intf, inet_ntoa(ip));
arp(/* ARPOP_REQUEST, */
示例12: avdtp_write
static int avdtp_write(struct bluetooth_data *data)
{
int ret = 0;
struct rtp_header *header;
struct rtp_payload *payload;
uint64_t now;
long duration = data->frame_duration * data->frame_count;
#ifdef ENABLE_TIMING
uint64_t begin, end, begin2, end2;
begin = get_microseconds();
#endif
header = (struct rtp_header *)data->buffer;
payload = (struct rtp_payload *)(data->buffer + sizeof(*header));
memset(data->buffer, 0, sizeof(*header) + sizeof(*payload));
payload->frame_count = data->frame_count;
header->v = 2;
header->pt = 1;
header->sequence_number = htons(data->seq_num);
header->timestamp = htonl(data->nsamples);
header->ssrc = htonl(1);
data->stream.revents = 0;
#ifdef ENABLE_TIMING
begin2 = get_microseconds();
#endif
ret = poll(&data->stream, 1, POLL_TIMEOUT);
#ifdef ENABLE_TIMING
end2 = get_microseconds();
print_time("poll Time Taken", begin2, end2);
#endif
if (ret == 1 && data->stream.revents == POLLOUT) {
long ahead = 0;
now = get_microseconds();
if (data->next_write) {
ahead = data->next_write - now;
#ifdef ENABLE_TIMING
DBG("duration: %ld, ahead: %ld", duration, ahead);
#endif
if (ahead > 0) {
/* too fast, need to throttle */
usleep(ahead);
}
} else {
data->next_write = now;
}
//DBG("duration: %ld, ahead: %ld", duration, ahead);
//DBG("decrease_bitpool %d",decrease_bitpool);
if(ahead <= -30*1000){
decrease_bitpool++;
if(decrease_bitpool > 2 ) {
DBG("duration: %ld, ahead: %ld", duration, ahead);
VDBG("calibrating Bitpool Decrease");
calibrate_bitpool(data,0);
decrease_bitpool = 0;
avdtp_good_counter=0;
}
} else if(ahead >= 10000){
if(data->sbc.bitpool != data->sbc_capabilities.max_bitpool){
avdtp_good_counter++;
if(avdtp_good_counter > 1000){//about 10 secs
DBG("duration: %ld, ahead: %ld avdtp_good_counter: %ld", duration, ahead, avdtp_good_counter);
calibrate_bitpool(data,1);
skip_avdtp_flow_check=0;
}
}
decrease_bitpool = 0;
}
if (ahead <= -CATCH_UP_TIMEOUT * 1000) {
/* fallen too far behind, don't try to catch up */
DBG("ahead < %d, reseting next_write timestamp", -CATCH_UP_TIMEOUT * 1000);
data->next_write = 0;
} else {
data->next_write += duration;
}
#ifdef ENABLE_TIMING
begin2 = get_microseconds();
#endif
pthread_mutex_lock(&data->lock);
if (data->stream.fd == -1) {
pthread_mutex_unlock(&data->lock);
return EBADF;
} else {
ret = send(data->stream.fd, data->buffer, data->count, MSG_NOSIGNAL);
}
pthread_mutex_unlock(&data->lock);
#ifdef ENABLE_TIMING
end2 = get_microseconds();
print_time("send", begin2, end2);
#endif
//.........这里部分代码省略.........
示例13: rx_complete
static void rx_complete(struct usb_ep *ep, struct usb_request *req)
{
struct sk_buff *skb = req->context;
struct eth_dev *dev = ep->driver_data;
int status = req->status;
bool queue = 0;
switch (status) {
/* normal completion */
case 0:
skb_put(skb, req->actual);
if (dev->unwrap) {
unsigned long flags;
spin_lock_irqsave(&dev->lock, flags);
if (dev->port_usb) {
status = dev->unwrap(dev->port_usb,
skb,
&dev->rx_frames);
if (status == -EINVAL)
dev->net->stats.rx_errors++;
else if (status == -EOVERFLOW)
dev->net->stats.rx_over_errors++;
} else {
dev_kfree_skb_any(skb);
status = -ENOTCONN;
}
spin_unlock_irqrestore(&dev->lock, flags);
} else {
skb_queue_tail(&dev->rx_frames, skb);
}
if (!status)
queue = 1;
break;
/* software-driven interface shutdown */
case -ECONNRESET: /* unlink */
case -ESHUTDOWN: /* disconnect etc */
VDBG(dev, "rx shutdown, code %d\n", status);
goto quiesce;
/* for hardware automagic (such as pxa) */
case -ECONNABORTED: /* endpoint reset */
DBG(dev, "rx %s reset\n", ep->name);
defer_kevent(dev, WORK_RX_MEMORY);
quiesce:
dev_kfree_skb_any(skb);
goto clean;
/* data overrun */
case -EOVERFLOW:
dev->net->stats.rx_over_errors++;
/* FALLTHROUGH */
default:
queue = 1;
dev_kfree_skb_any(skb);
dev->net->stats.rx_errors++;
DBG(dev, "rx status %d\n", status);
break;
}
clean:
spin_lock(&dev->req_lock);
list_add(&req->list, &dev->rx_reqs);
spin_unlock(&dev->req_lock);
if (queue)
queue_work(uether_wq, &dev->rx_work);
}
示例14: otg_set_state
/* Called when entering a state */
static int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state)
{
state_changed = 1;
if (fsm->otg->phy->state == new_state)
return 0;
VDBG("Set state: %s\n", usb_otg_state_string(new_state));
otg_leave_state(fsm, fsm->otg->phy->state);
switch (new_state) {
case OTG_STATE_B_IDLE:
otg_drv_vbus(fsm, 0);
otg_chrg_vbus(fsm, 0);
otg_loc_conn(fsm, 0);
otg_loc_sof(fsm, 0);
/*
* Driver is responsible for starting ADP probing
* if ADP sensing times out.
*/
otg_start_adp_sns(fsm);
otg_set_protocol(fsm, PROTO_UNDEF);
otg_add_timer(fsm, B_SE0_SRP);
break;
case OTG_STATE_B_SRP_INIT:
otg_start_pulse(fsm);
otg_loc_sof(fsm, 0);
otg_set_protocol(fsm, PROTO_UNDEF);
otg_add_timer(fsm, B_SRP_FAIL);
break;
case OTG_STATE_B_PERIPHERAL:
otg_chrg_vbus(fsm, 0);
otg_loc_sof(fsm, 0);
otg_set_protocol(fsm, PROTO_GADGET);
otg_loc_conn(fsm, 1);
break;
case OTG_STATE_B_WAIT_ACON:
otg_chrg_vbus(fsm, 0);
otg_loc_conn(fsm, 0);
otg_loc_sof(fsm, 0);
otg_set_protocol(fsm, PROTO_HOST);
otg_add_timer(fsm, B_ASE0_BRST);
fsm->a_bus_suspend = 0;
break;
case OTG_STATE_B_HOST:
otg_chrg_vbus(fsm, 0);
otg_loc_conn(fsm, 0);
otg_loc_sof(fsm, 1);
otg_set_protocol(fsm, PROTO_HOST);
usb_bus_start_enum(fsm->otg->host,
fsm->otg->host->otg_port);
break;
case OTG_STATE_A_IDLE:
otg_drv_vbus(fsm, 0);
otg_chrg_vbus(fsm, 0);
otg_loc_conn(fsm, 0);
otg_loc_sof(fsm, 0);
otg_start_adp_prb(fsm);
otg_set_protocol(fsm, PROTO_HOST);
break;
case OTG_STATE_A_WAIT_VRISE:
otg_drv_vbus(fsm, 1);
otg_loc_conn(fsm, 0);
otg_loc_sof(fsm, 0);
otg_set_protocol(fsm, PROTO_HOST);
otg_add_timer(fsm, A_WAIT_VRISE);
break;
case OTG_STATE_A_WAIT_BCON:
otg_drv_vbus(fsm, 1);
otg_loc_conn(fsm, 0);
otg_loc_sof(fsm, 0);
otg_set_protocol(fsm, PROTO_HOST);
otg_add_timer(fsm, A_WAIT_BCON);
break;
case OTG_STATE_A_HOST:
otg_drv_vbus(fsm, 1);
otg_loc_conn(fsm, 0);
otg_loc_sof(fsm, 1);
otg_set_protocol(fsm, PROTO_HOST);
/*
* When HNP is triggered while a_bus_req = 0, a_host will
* suspend too fast to complete a_set_b_hnp_en
*/
if (!fsm->a_bus_req || fsm->a_suspend_req_inf)
otg_add_timer(fsm, A_WAIT_ENUM);
break;
case OTG_STATE_A_SUSPEND:
otg_drv_vbus(fsm, 1);
otg_loc_conn(fsm, 0);
otg_loc_sof(fsm, 0);
otg_set_protocol(fsm, PROTO_HOST);
otg_add_timer(fsm, A_AIDL_BDIS);
break;
case OTG_STATE_A_PERIPHERAL:
otg_loc_sof(fsm, 0);
otg_set_protocol(fsm, PROTO_GADGET);
otg_drv_vbus(fsm, 1);
otg_loc_conn(fsm, 1);
otg_add_timer(fsm, A_BIDL_ADIS);
break;
case OTG_STATE_A_WAIT_VFALL:
//.........这里部分代码省略.........
示例15: otg_statemachine
/* State change judgement */
int otg_statemachine(struct otg_fsm *fsm)
{
enum usb_otg_state state;
unsigned long flags;
spin_lock_irqsave(&fsm->lock, flags);
state = fsm->transceiver->state;
state_changed = 0;
/* State machine state change judgement */
VDBG("top: curr state=%s", state_string(state));
switch (state) {
case OTG_STATE_UNDEFINED:
VDBG("fsm->id = %d", fsm->id);
if (fsm->id)
otg_set_state(fsm, OTG_STATE_B_IDLE);
else
otg_set_state(fsm, OTG_STATE_A_IDLE);
break;
case OTG_STATE_B_IDLE:
VDBG("gadget: %p", fsm->transceiver->gadget);
if (!fsm->id)
otg_set_state(fsm, OTG_STATE_A_IDLE);
else if (fsm->b_sess_vld && fsm->transceiver->gadget)
otg_set_state(fsm, OTG_STATE_B_PERIPHERAL);
else if (fsm->b_bus_req && fsm->b_sess_end && fsm->b_se0_srp)
otg_set_state(fsm, OTG_STATE_B_SRP_INIT);
break;
case OTG_STATE_B_SRP_INIT:
if (!fsm->id || fsm->b_srp_done)
otg_set_state(fsm, OTG_STATE_B_IDLE);
break;
case OTG_STATE_B_PERIPHERAL:
if (!fsm->id || !fsm->b_sess_vld)
otg_set_state(fsm, OTG_STATE_B_IDLE);
else if (fsm->b_bus_req &&
fsm->transceiver->gadget->b_hnp_enable &&
fsm->a_bus_suspend)
otg_set_state(fsm, OTG_STATE_B_WAIT_ACON);
break;
case OTG_STATE_B_WAIT_ACON:
if (fsm->a_conn)
otg_set_state(fsm, OTG_STATE_B_HOST);
else if (!fsm->id || !fsm->b_sess_vld)
otg_set_state(fsm, OTG_STATE_B_IDLE);
else if (fsm->a_bus_resume || fsm->b_ase0_brst_tmout) {
fsm->b_ase0_brst_tmout = 0;
otg_set_state(fsm, OTG_STATE_B_PERIPHERAL);
}
break;
case OTG_STATE_B_HOST:
if (!fsm->id || !fsm->b_sess_vld)
otg_set_state(fsm, OTG_STATE_B_IDLE);
else if (!fsm->b_bus_req || !fsm->a_conn)
otg_set_state(fsm, OTG_STATE_B_PERIPHERAL);
break;
case OTG_STATE_A_IDLE:
if (fsm->id)
otg_set_state(fsm, OTG_STATE_B_IDLE);
else if (!fsm->a_bus_drop && (fsm->a_bus_req || fsm->a_srp_det))
otg_set_state(fsm, OTG_STATE_A_WAIT_VRISE);
break;
case OTG_STATE_A_WAIT_VRISE:
if (fsm->id || fsm->a_bus_drop || fsm->a_vbus_vld ||
fsm->a_wait_vrise_tmout) {
otg_set_state(fsm, OTG_STATE_A_WAIT_BCON);
}
break;
case OTG_STATE_A_WAIT_BCON:
if (!fsm->a_vbus_vld)
otg_set_state(fsm, OTG_STATE_A_VBUS_ERR);
else if (fsm->b_conn)
otg_set_state(fsm, OTG_STATE_A_HOST);
else if (fsm->id | fsm->a_bus_drop | fsm->a_wait_bcon_tmout)
otg_set_state(fsm, OTG_STATE_A_WAIT_VFALL);
break;
case OTG_STATE_A_HOST:
if ((!fsm->a_bus_req || fsm->a_suspend_req) &&
fsm->transceiver->host->b_hnp_enable)
otg_set_state(fsm, OTG_STATE_A_SUSPEND);
else if (fsm->id || !fsm->b_conn || fsm->a_bus_drop)
otg_set_state(fsm, OTG_STATE_A_WAIT_BCON);
else if (!fsm->a_vbus_vld)
otg_set_state(fsm, OTG_STATE_A_VBUS_ERR);
break;
case OTG_STATE_A_SUSPEND:
if (!fsm->b_conn && fsm->transceiver->host->b_hnp_enable)
otg_set_state(fsm, OTG_STATE_A_PERIPHERAL);
else if (!fsm->b_conn && !fsm->transceiver->host->b_hnp_enable)
otg_set_state(fsm, OTG_STATE_A_WAIT_BCON);
else if (fsm->a_bus_req || fsm->b_bus_resume)
otg_set_state(fsm, OTG_STATE_A_HOST);
else if (fsm->id || fsm->a_bus_drop || fsm->a_aidl_bdis_tmout)
otg_set_state(fsm, OTG_STATE_A_WAIT_VFALL);
else if (!fsm->a_vbus_vld)
otg_set_state(fsm, OTG_STATE_A_VBUS_ERR);
break;
//.........这里部分代码省略.........