PUBLIC void objectstore_datum_array_set(ObjectStoreDatum *array, int index, ObjectStoreDatum *value) { RETURN_UNLESS(array->kind == OSI_KIND_ARRAY); g_return_if_fail(index >= 0); g_return_if_fail(index < array->d.array.count); if (array->d.array.elts[index] != NULL) objectstore_kill_objectstoredatum(array->d.array.elts[index]); array->d.array.elts[index] = value; }
/*! pmic_otg_event_bh - pmic otg event handler * @param data - otg instance */ void pmic_otg_event_bh(void *data) { struct otg_instance *otg = (struct otg_instance *) data; otg_current_t inputs; t_sensor_bits sense_bits; static BOOL force = TRUE; static otg_current_t inputs_saved = 0; if (pmic_get_sensors(&sense_bits)) { printk(KERN_INFO "%s: pmic_get_sensors() failed\n", __FUNCTION__); return; } TRACE_MSG6(REMOVE_TCD, "usb4v4s%c usb2v0s%c usb0v8s:%c id_gnds%c id_floats%c id_se1s%c", sense_bits.sense_usb4v4s ? ' ' : '/', sense_bits.sense_usb2v0s ? ' ' : '/', sense_bits.sense_usb0v8s ? ' ' : '/', sense_bits.sense_id_gnds ? ' ' : '/', sense_bits.sense_id_floats ? ' ' : '/', sense_bits.sense_se1s ? ' ' : '/'); inputs = (sense_bits.sense_usb4v4s ? VBUS_VLD : VBUS_VLD_) | (sense_bits. sense_usb2v0s ? (B_SESS_VLD | A_SESS_VLD) : (B_SESS_VLD_ | A_SESS_VLD_)) | (sense_bits.sense_usb0v8s ? B_SESS_END_ : B_SESS_END) | (sense_bits. sense_id_gnds ? ID_GND : ID_GND_) | (sense_bits.sense_id_floats ? ID_FLOAT : ID_FLOAT_) | (sense_bits. sense_se1s ? SE1_DET : SE1_DET_) | (det_dp_hi ? DP_HIGH : DP_HIGH_) | (det_dm_hi ? DM_HIGH : DM_HIGH_); // printk(KERN_INFO" inputs: %8X\n", inputs); TRACE_MSG4(REMOVE_TCD, "MC13783 EVENT: sense_bits: %8x otg inputs: %8x saved: %x diff: %x", sense_bits.sense_se1s, inputs, inputs_saved, inputs ^ inputs_saved); RETURN_UNLESS(force || (inputs ^ inputs_saved)); inputs_saved = inputs; otg_event(REMOVE_tcd_instance->otg, inputs, REMOVE_TCD, "PMIC OTG EVENT"); // gpio_config_int_en(2, 17, TRUE); // gpio_config_int_en(2, 16, TRUE); // gpio_clear_int (2, 17); // gpio_clear_int (2, 16); }
PRIVATE void audio_play_fragment(int audiofd, SAMPLE *left, SAMPLE *right, int length) { OUTPUTSAMPLE *outbuf; int buflen = length * sizeof(OUTPUTSAMPLE) * 2; int i; if (length <= 0) return; outbuf = malloc(buflen); RETURN_UNLESS(outbuf != NULL); for (i = 0; i < length; i++) { outbuf[i<<1] = (OUTPUTSAMPLE) MIN(MAX(left[i] * 32767, -32768), 32767); outbuf[(i<<1) + 1] = (OUTPUTSAMPLE) MIN(MAX(right[i] * 32767, -32768), 32767); } write(audiofd, outbuf, buflen); free(outbuf); }
/*! * otg_pci_free_dev */ void otg_pci_free_dev(struct pci_dev *pci_dev, struct otg_dev *otg_dev) { int region; unsigned long resource_start; unsigned long resource_len; RETURN_UNLESS(otg_dev); for (region = 0; region < DEVICE_COUNT_RESOURCE; region++) { CONTINUE_UNLESS(otg_dev->pci_regions & (1 << region)); if (otg_dev->regs[region]) iounmap(otg_dev->regs[region]); resource_start = pci_resource_start(pci_dev, region); resource_len = pci_resource_len(pci_dev, region); release_mem_region(resource_start, resource_len); } }
void mxc_hrt_callback (unsigned long arg) { TRACE_MSG1(OCD, "checking active: %d", mxc_hr_active); RETURN_UNLESS(mxc_hr_active); mxc_hr_active = FALSE; TRACE_MSG1(OCD, "resetting active: %d", mxc_hr_active); if (mxc_hr_usec_set >= 1000000) { //if requested period is in the range of 1 sec hr_timer.expires = jiffies + ((mxc_hr_usec_set/1000000)*mxc_hr_jiffy_per_sec); hr_timer.arch_cycle_expires = get_arch_cycles(jiffies); hr_timer.function = mxc_hrt_callback; } else { hr_timer.expires = jiffies; hr_timer.arch_cycle_expires = get_arch_cycles(jiffies); if (mxc_hr_usec_set < 100) { TRACE_MSG1(OCD, "usec: %d set to minimum 100", mxc_hr_usec_set); mxc_hr_usec_set = 100; } hr_timer.arch_cycle_expires += nsec_to_arch_cycle(mxc_hr_usec_set * 1000); //hr_timer.arch_cycle_expires += nsec_to_arch_cycle(100 * 1000 * 1000); while (hr_timer.arch_cycle_expires >= arch_cycles_per_jiffy) { hr_timer.expires++; hr_timer.arch_cycle_expires -= arch_cycles_per_jiffy; } } //end of else TRACE_MSG3 (OCD, "usec: %d expires: %8u arch_cycle_expires: %8u", mxc_hr_usec_set, hr_timer.expires, hr_timer.arch_cycle_expires); otg_event(ocd_instance->otg, TMOUT, OCD, "TMOUT"); // add_timer(&hr_timer); }
void mc13783_otg_event_bh (void *arg) { u64 inputs; t_sense_bits sense_bits; static BOOL force = TRUE; static u64 inputs_saved = 0; // Note: power_ic has USB4V4S labelled as USBI, which is incorrect // Get the sense bits, return if any fail to be read. if ( (sense_bits.sense_usb4v4s = power_ic_event_sense_read(POWER_IC_EVENT_ATLAS_USBI)) < 0) { printk(KERN_INFO"%s: mc13783_get_sense() usb4v4s failed\n", __FUNCTION__); return; } if ( (sense_bits.sense_usb2v0s = power_ic_event_sense_read(POWER_IC_EVENT_ATLAS_USB2V0S)) < 0) { printk(KERN_INFO"%s: mc13783_get_sense() usb2v0s failed\n", __FUNCTION__); return; } if ( (sense_bits.sense_usb0v8s = power_ic_event_sense_read(POWER_IC_EVENT_ATLAS_USB0V8S)) < 0) { printk(KERN_INFO"%s: mc13783_get_sense() usb0v8s failed\n", __FUNCTION__); return; } if ( (sense_bits.sense_id_floats = power_ic_event_sense_read(POWER_IC_EVENT_ATLAS_ID_FLOAT)) < 0) { printk(KERN_INFO"%s: mc13783_get_sense() id_floats failed\n", __FUNCTION__); return; } if ( (sense_bits.sense_id_gnds = power_ic_event_sense_read(POWER_IC_EVENT_ATLAS_ID_GROUND)) < 0) { printk(KERN_INFO"%s: mc13783_get_sense() id_gnds failed\n", __FUNCTION__); return; } if ( (sense_bits.sense_se1s = power_ic_event_sense_read(POWER_IC_EVENT_ATLAS_SE1I)) < 0) { printk(KERN_INFO"%s: mc13783_get_sense() se1s failed\n", __FUNCTION__); return; } // Factory cable check meant for USB B device only. If IDGNDS is True // adjust the value of IDGNDS to be False, so the state machine thinks it's a // traditional device and not a Dual role device. #ifdef CONFIG_OTG_USB_PERIPHERAL if ( sense_bits.sense_id_gnds ) { sense_bits.sense_id_gnds = FALSE; TRACE_MSG0(TCD, "Factory Cable detected and IDGND modified to false"); // printk("Factory Cable detected and IDGND modified to false\n"); } #endif inputs = (sense_bits.sense_usb4v4s ? VBUS_VLD : VBUS_VLD_) | (sense_bits.sense_usb2v0s ? (B_SESS_VLD | A_SESS_VLD) : (B_SESS_VLD_ | A_SESS_VLD_)) | (sense_bits.sense_usb0v8s ? B_SESS_END_ : B_SESS_END) | (sense_bits.sense_id_gnds ? ID_GND : ID_GND_) | (sense_bits.sense_id_floats ? ID_FLOAT : ID_FLOAT_) | (sense_bits.sense_se1s ? SE1_DET : SE1_DET_) | (det_dp_hi ? DP_HIGH : DP_HIGH_) | (det_dm_hi ? DM_HIGH : DM_HIGH_); TRACE_MSG4(TCD, "MC13783 EVENT: sense_bits: %8x otg inputs: %8x saved: %x diff: %x", sense_bits.sense_se1s, inputs, inputs_saved, inputs ^ inputs_saved); RETURN_UNLESS(force || (inputs ^ inputs_saved)); inputs_saved = inputs; otg_event(tcd_instance->otg, inputs, TCD, "MC13783 OTG EVENT"); }
/*! * generic_cf_register() * */ void generic_cf_register(struct generic_config *config, char *match) { char *cp, *sp, *lp; int i; char **interface_list = NULL; int interfaces = 0; //printk(KERN_INFO"%s: Driver: \"%s\" idVendor: %04x idProduct: %04x interface_names: \"%s\" match: \"%s\"\n", // __FUNCTION__, // config->composite_driver.driver.name, MODPARM(idVendor), MODPARM(idProduct), config->interface_names, // match ? match : ""); TRACE_MSG5(GENERIC, "Driver: \"%s\" idVendor: %04x idProduct: %04x interface_names: \"%s\" match: \"%s\"", config->composite_driver.driver.name, MODPARM(idVendor), MODPARM(idProduct), config->interface_names, match ? match : ""); RETURN_IF (match && strlen(match) && strcmp(match, config->composite_driver.driver.name)); //printk(KERN_INFO"%s: MATCHED\n", __FUNCTION__); /* decompose interface names to construct interface_list */ RETURN_UNLESS (config->interface_names && strlen(config->interface_names)); /* count interface names and allocate _interface_names array */ for (cp = sp = config->interface_names, interfaces = 0; cp && *cp; ) { for (; *cp && *cp == ':'; cp++); // skip white space sp = cp; // save start of token for (; *cp && *cp != ':'; cp++); // find end of token BREAK_IF (sp == cp); if (*cp) cp++; interfaces++; } THROW_UNLESS(interfaces, error); TRACE_MSG1(GENERIC, "interfaces: %d", interfaces); THROW_UNLESS((interface_list = (char **) CKMALLOC (sizeof (char *) * (interfaces + 1), GFP_KERNEL)), error); for (cp = sp = config->interface_names, interfaces = 0; cp && *cp; interfaces++) { for (; *cp && *cp == ':'; cp++); // skip white space sp = cp; // save start of token for (; *cp && *cp != ':'; cp++); // find end of token BREAK_IF (sp == cp); lp = cp; if (*cp) cp++; *lp = '\0'; lp = CKMALLOC(strlen(sp), GFP_KERNEL); strcpy(lp, sp); interface_list[interfaces] = lp; TRACE_MSG3(GENERIC, "INTERFACE[%2d] %x \"%s\"", interfaces, interface_list[interfaces], interface_list[interfaces]); } config->composite_driver.device_description = &config->device_description; config->composite_driver.configuration_description = &config->configuration_description; config->composite_driver.driver.fops = &generic_function_ops; config->interface_list = interface_list; THROW_IF (usbd_register_composite_function ( &config->composite_driver, config->composite_driver.driver.name, config->class_name, config->interface_list, NULL), error); config->registered++; TRACE_MSG0(GENERIC, "REGISTER FINISHED"); CATCH(error) { otg_trace_invalidate_tag(GENERIC); } }