void Parse::emit_guard_for_new(ciInstanceKlass* klass) { // Emit guarded new // if (klass->_init_thread != current_thread || // klass->_init_state != being_initialized) // uncommon_trap Node* cur_thread = _gvn.transform( new (C, 1) ThreadLocalNode() ); Node* merge = new (C, 3) RegionNode(3); _gvn.set_type(merge, Type::CONTROL); Node* kls = makecon(TypeKlassPtr::make(klass)); Node* init_thread_offset = _gvn.MakeConX(instanceKlass::init_thread_offset_in_bytes() + klassOopDesc::klass_part_offset_in_bytes()); Node* adr_node = basic_plus_adr(kls, kls, init_thread_offset); Node* init_thread = make_load(NULL, adr_node, TypeRawPtr::BOTTOM, T_ADDRESS); Node *tst = Bool( CmpP( init_thread, cur_thread), BoolTest::eq); IfNode* iff = create_and_map_if(control(), tst, PROB_ALWAYS, COUNT_UNKNOWN); set_control(IfTrue(iff)); merge->set_req(1, IfFalse(iff)); Node* init_state_offset = _gvn.MakeConX(instanceKlass::init_state_offset_in_bytes() + klassOopDesc::klass_part_offset_in_bytes()); adr_node = basic_plus_adr(kls, kls, init_state_offset); Node* init_state = make_load(NULL, adr_node, TypeInt::INT, T_INT); Node* being_init = _gvn.intcon(instanceKlass::being_initialized); tst = Bool( CmpI( init_state, being_init), BoolTest::eq); iff = create_and_map_if(control(), tst, PROB_ALWAYS, COUNT_UNKNOWN); set_control(IfTrue(iff)); merge->set_req(2, IfFalse(iff)); PreserveJVMState pjvms(this); record_for_igvn(merge); set_control(merge); uncommon_trap(Deoptimization::Reason_uninitialized, Deoptimization::Action_reinterpret, klass); }
void msr(int i) { unsigned int n; *((int *)(&moveToStatus)) = i; n=(unsigned int) moveToStatus.rn; if(Bad_Reg(n)) printf("UNPREDICTABLE instruciton\n"); else{ unsigned sysmTemp=moveToStatus.sysm; sysmTemp=sysmTemp>>3; sysmTemp&=0x01F; if(sysmTemp==0){ if(!(moveToStatus.sysm & 0x04)) set_apsr(get_general_register(moveToStatus.rn)>>27); } else if(sysmTemp==1){ if(CurrentModeIsPrivileged()){ if((moveToStatus.sysm & 0x07)==0) set_msp(get_general_register(moveToStatus.rn)); else if((moveToStatus.sysm & 0x07)==1) set_psp(get_general_register(moveToStatus.rn)); } } else if(sysmTemp==2){ unsigned int temp=(moveToStatus.sysm & 0x07); if(temp==0 && CurrentModeIsPrivileged()){ set_primask(get_general_register(moveToStatus.rn)&0x01); } else if(temp==1 && CurrentModeIsPrivileged()){ set_basepri(get_general_register(moveToStatus.rn)&0xFF); } else if(temp==2 && CurrentModeIsPrivileged()){ if((get_general_register(moveToStatus.rn)&0xFF)!=0 && ((get_general_register(moveToStatus.rn)&0xFF)!=0) && (((get_general_register(moveToStatus.rn)&0xFF)<get_basepri()) || get_basepri()==0)) set_basepri(get_general_register(moveToStatus.rn)&0xFF); } else if(temp==3 && CurrentModeIsPrivileged() && (ExecutionPriority() > -1)){ set_faultmask(get_general_register(moveToStatus.rn)&0x01); } else if(temp==4 && CurrentModeIsPrivileged()){ /* when `100` if CurrentModeIsPrivileged() then CONTROL<0> = R[n]<1:0>; If Mode == Thread then CONTROL<1> = R[n]<1>; */// question set_control((get_control()&0xFFFFFFFE)|(get_general_register(moveToStatus.rn)&0x01)); if(GetMode()==THREAD) set_control((get_control()&0xFFFFFFFD)|(get_general_register(moveToStatus.rn)&0x02)); } } }
static int hss_open(int port, void *pdev, void (*set_carrier_cb)(void *pdev, int carrier)) { int i, irq; if (!port) irq = gpio_irq(GPIO_HSS0_DCD_N); else irq = gpio_irq(GPIO_HSS1_DCD_N); gpio_line_get(port ? GPIO_HSS1_DCD_N : GPIO_HSS0_DCD_N, &i); set_carrier_cb(pdev, !i); set_carrier_cb_tab[!!port] = set_carrier_cb; if ((i = request_irq(irq, hss_dcd_irq, 0, "IXP4xx HSS", pdev)) != 0) { printk(KERN_ERR "ixp4xx_hss: failed to request IRQ%i (%i)\n", irq, i); return i; } set_control(port ? CONTROL_HSS1_DTR_N : CONTROL_HSS0_DTR_N, 0); output_control(); gpio_line_set(port ? GPIO_HSS1_RTS_N : GPIO_HSS0_RTS_N, 0); return 0; }
Node* gen_subtype_check(Node* subklass, Node* superklass) { MergeMemNode* mem = merged_memory(); Node* ctrl = control(); Node* n = Phase::gen_subtype_check(subklass, superklass, &ctrl, mem, &_gvn); set_control(ctrl); return n; }
static int i2c_read(struct i2c_algo_sgi_data *adap, unsigned char *buf, unsigned int len) { int i; set_control(SGI_I2C_HOLD_BUS | SGI_I2C_READ | SGI_I2C_NOT_IDLE); for (i = 0; i < len; i++) { if (wait_xfer_done(adap)) return -EIO; buf[i] = read_data(); } set_control(SGI_I2C_RELEASE_BUS | SGI_I2C_FORCE_IDLE); return 0; }
void InputEventWithModifiers::set_modifiers_from_event(const InputEventWithModifiers *event) { set_alt(event->get_alt()); set_shift(event->get_shift()); set_control(event->get_control()); set_metakey(event->get_metakey()); }
CommandResponsePacket send_command_and_receive_response(uvc::device & device, const CommandResponsePacket & command) { CommandResponsePacket c = command, r; set_control(device, lr_xu, static_cast<int>(control::command_response), &c, sizeof(c)); get_control(device, lr_xu, static_cast<int>(control::command_response), &r, sizeof(r)); return r; }
static int do_address(struct i2c_algo_sgi_data *adap, unsigned int addr, int rd) { if (rd) set_control(SGI_I2C_NOT_IDLE); /* Check if bus is idle, eventually force it to do so */ if (get_control() & SGI_I2C_NOT_IDLE) if (force_idle(adap)) return -EIO; /* Write out the i2c chip address and specify operation */ set_control(SGI_I2C_HOLD_BUS | SGI_I2C_WRITE | SGI_I2C_NOT_IDLE); if (rd) addr |= 1; write_data(addr); if (wait_ack(adap)) return -EIO; return 0; }
void msx_cart_disk_type2::post_load() { UINT8 data = m_control; // To make sure the FDD busy led status gets set correctly m_control ^= 0x40; set_control(data); }
void msx_slot_disk2_device::post_load() { UINT8 data = m_control; // To make sure the FDD busy led status gets set correctly m_control ^= 0x40; set_control(data); }
void msx_cart_disk_type1_device::post_load() { uint8_t data = m_control; // To make sure the FDD busy led status gets set correctly m_control ^= 0x40; set_control(data); }
static void hss_close(int port, void *pdev) { free_irq(port ? gpio_irq(GPIO_HSS1_DCD_N) : gpio_irq(GPIO_HSS0_DCD_N), pdev); set_carrier_cb_tab[!!port] = NULL; /* catch bugs */ set_control(port ? CONTROL_HSS1_DTR_N : CONTROL_HSS0_DTR_N, 1); output_control(); gpio_line_set(port ? GPIO_HSS1_RTS_N : GPIO_HSS0_RTS_N, 1); }
static int hss_set_clock(int port, unsigned int clock_type) { int ctrl_int = port ? CONTROL_HSS1_CLK_INT : CONTROL_HSS0_CLK_INT; switch (clock_type) { case CLOCK_DEFAULT: case CLOCK_EXT: set_control(ctrl_int, 0); output_control(); return CLOCK_EXT; case CLOCK_INT: set_control(ctrl_int, 1); output_control(); return CLOCK_INT; default: return -EINVAL; } }
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags) { LADSPA_Data value; unsigned long port; if (sscanf(cmd, "c%ld", &port) + sscanf(args, "%f", &value) != 2) return AVERROR(EINVAL); return set_control(ctx, port, value); }
void Nunchuk::LoadDefaults(const ControllerInterface& ciface) { // ugly macroooo #define set_control(group, num, str) (group)->controls[num]->control_ref->expression = (str) // Stick set_control(m_stick, 0, "W"); // up set_control(m_stick, 1, "S"); // down set_control(m_stick, 2, "A"); // left set_control(m_stick, 3, "D"); // right // Buttons #ifdef _WIN32 set_control(m_buttons, 0, "LCONTROL"); // C set_control(m_buttons, 1, "LSHIFT"); // Z #elif __APPLE__ set_control(m_buttons, 0, "Left Control"); // C set_control(m_buttons, 1, "Left Shift"); // Z #else set_control(m_buttons, 0, "Control_L"); // C set_control(m_buttons, 1, "Shift_L"); // Z #endif }
static int force_idle(struct i2c_algo_sgi_data *adap) { int i; set_control(SGI_I2C_FORCE_IDLE); for (i = 0; i < adap->xfer_timeout; i++) { if ((get_control() & SGI_I2C_NOT_IDLE) == 0) goto out; udelay(1); } return -ETIMEDOUT; out: if (get_control() & SGI_I2C_BUS_ERR) return -EIO; return 0; }
int QcomFmIoctlsInterface :: set_band ( UINT fd, ULINT low, ULINT high ) { int ret; struct v4l2_tuner tuner; tuner.index = 0; tuner.signal = 0; tuner.rangelow = (low * TUNE_MULT); tuner.rangehigh = (high * TUNE_MULT); ret = ioctl(fd, VIDIOC_S_TUNER, &tuner); ret = set_control(fd, V4L2_CID_PRV_REGION, 0); if(ret != IOCTL_SUCC) { return FM_FAILURE; }else { return FM_SUCCESS; } }
cell_t * run_secd(secd_t *secd, cell_t *ctrl) { cell_t *op, *ret; TIMING_DECLARATIONS(ts_then, ts_now); share_cell(secd, ctrl); set_control(secd, &ctrl); while (true) { TIMING_START_OPERATION(ts_then); op = pop_control(secd); assert_cell(op, "run: no command"); if (cell_type(op) != CELL_OP) { errorf("run: not an opcode at [%ld]\n", cell_index(secd, op)); dbg_printc(secd, op); continue; } int opind = op->as.op; if (about_to_halt(secd, opind, &ret)) return ret; secd_opfunc_t callee = (secd_opfunc_t) opcode_table[ opind ].fun; ret = callee(secd); if (is_error(ret)) if (!handle_exception(secd, ret)) return fatal_exception(secd, ret, opind); drop_cell(secd, op); TIMING_END_OPERATION(ts_then, ts_now) run_postop(secd); ++secd->tick; } }
static void __init gmlr_init(void) { u8 __iomem *flash; int i, devices = 1; /* flash */ ixp4xx_sys_init(); if ((flash = ioremap(IXP4XX_EXP_BUS_BASE_PHYS, 0x80)) == NULL) printk(KERN_ERR "goramo-mlr: unable to access system" " configuration data\n"); else { system_rev = __raw_readl(flash + CFG_REV); hw_bits = __raw_readl(flash + CFG_HW_BITS); for (i = 0; i < ETH_ALEN; i++) { eth_plat[0].hwaddr[i] = flash_readb(flash, CFG_ETH0_ADDRESS + i); eth_plat[1].hwaddr[i] = flash_readb(flash, CFG_ETH1_ADDRESS + i); } __raw_writew(FLASH_CMD_READ_ID, flash); system_serial_high = flash_readw(flash, FLASH_SER_OFF); system_serial_high <<= 16; system_serial_high |= flash_readw(flash, FLASH_SER_OFF + 2); system_serial_low = flash_readw(flash, FLASH_SER_OFF + 4); system_serial_low <<= 16; system_serial_low |= flash_readw(flash, FLASH_SER_OFF + 6); __raw_writew(FLASH_CMD_READ_ARRAY, flash); iounmap(flash); } switch (hw_bits & (CFG_HW_HAS_UART0 | CFG_HW_HAS_UART1)) { case CFG_HW_HAS_UART0: memset(&uart_data[1], 0, sizeof(uart_data[1])); device_uarts.num_resources = 1; break; case CFG_HW_HAS_UART1: device_uarts.dev.platform_data = &uart_data[1]; device_uarts.resource = &uart_resources[1]; device_uarts.num_resources = 1; break; } if (hw_bits & (CFG_HW_HAS_UART0 | CFG_HW_HAS_UART1)) device_tab[devices++] = &device_uarts; /* max index 1 */ if (hw_bits & CFG_HW_HAS_ETH0) device_tab[devices++] = &device_eth_tab[0]; /* max index 2 */ if (hw_bits & CFG_HW_HAS_ETH1) device_tab[devices++] = &device_eth_tab[1]; /* max index 3 */ if (hw_bits & CFG_HW_HAS_HSS0) device_tab[devices++] = &device_hss_tab[0]; /* max index 4 */ if (hw_bits & CFG_HW_HAS_HSS1) device_tab[devices++] = &device_hss_tab[1]; /* max index 5 */ if (hw_bits & CFG_HW_HAS_EEPROM) device_tab[devices++] = &device_i2c; /* max index 6 */ gpio_line_config(GPIO_SCL, IXP4XX_GPIO_OUT); gpio_line_config(GPIO_SDA, IXP4XX_GPIO_OUT); gpio_line_config(GPIO_STR, IXP4XX_GPIO_OUT); gpio_line_config(GPIO_HSS0_RTS_N, IXP4XX_GPIO_OUT); gpio_line_config(GPIO_HSS1_RTS_N, IXP4XX_GPIO_OUT); gpio_line_config(GPIO_HSS0_DCD_N, IXP4XX_GPIO_IN); gpio_line_config(GPIO_HSS1_DCD_N, IXP4XX_GPIO_IN); set_irq_type(gpio_irq(GPIO_HSS0_DCD_N), IRQ_TYPE_EDGE_BOTH); set_irq_type(gpio_irq(GPIO_HSS1_DCD_N), IRQ_TYPE_EDGE_BOTH); set_control(CONTROL_HSS0_DTR_N, 1); set_control(CONTROL_HSS1_DTR_N, 1); set_control(CONTROL_EEPROM_WC_N, 1); set_control(CONTROL_PCI_RESET_N, 1); output_control(); msleep(1); /* Wait for PCI devices to initialize */ flash_resource.start = IXP4XX_EXP_BUS_BASE(0); flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1; platform_add_devices(device_tab, devices); }
int main(int argc, char *argv[]) { if (argc >= 1 && NULL != argv[0]) { size_t n = strlen(argv[0]) + 1; program_name = allocate(n); strlcpy(program_name, argv[0], n); } static const char short_options[] = "hvd:c:"; static const struct option long_options[] = { { "help", no_argument, NULL, 'h' }, { "verbose", no_argument, NULL, 'v' }, { "device", required_argument, NULL, 'd' }, { "count", required_argument, NULL, 'c' }, { 0, 0, 0, 0 } }; device_name = "/dev/video0"; int verbose = 0; int count = 0; for (;;) { int idx; int c; c = getopt_long(argc, argv, short_options, long_options, &idx); if (-1 == c) { break; } switch (c) { case 0: // getopt_long() flag break; case 'v': ++verbose; break; case 'd': device_name = optarg; break; case 'c': errno = 0; count = strtol(optarg, NULL, 0); if (0 != errno) { usage("invalid count '%s': %d, %s", optarg, errno, strerror(errno)); } break; case 'h': usage(NULL); return 0; default: usage("invalid option: %c", c); } } if (count <= 0) { usage("invalid count: %d", count); } int fd = open_device(device_name); uint32_t default_hue = CHECK(fd, V4L2_CID_HUE); uint32_t default_contrast = CHECK(fd, V4L2_CID_CONTRAST); uint32_t default_sharpness = CHECK(fd, V4L2_CID_SHARPNESS); uint32_t default_brightness = CHECK(fd, V4L2_CID_BRIGHTNESS); for (int n = 0; n < count; ++n) { printf("loop: %d\n", n); for (int32_t value = 1; value < 16; value <<= 1) { printf(" set: 0x%04x\n", value); set_leds(fd, value); usleep(500000); } } // set all off printf("turn off\n"); set_leds(fd, 0); set_control(fd, V4L2_CID_HUE, default_hue); set_control(fd, V4L2_CID_CONTRAST, default_contrast); set_control(fd, V4L2_CID_SHARPNESS, default_sharpness); set_control(fd, V4L2_CID_BRIGHTNESS, default_brightness); // finished close(fd); return 0; }
//--------------------gen_stub------------------------------- void GraphKit::gen_stub(address C_function, const char *name, int is_fancy_jump, bool pass_tls, bool return_pc) { ResourceMark rm; const TypeTuple *jdomain = C->tf()->domain(); const TypeTuple *jrange = C->tf()->range(); // The procedure start StartNode* start = new (C) StartNode(root(), jdomain); _gvn.set_type_bottom(start); // Make a map, with JVM state uint parm_cnt = jdomain->cnt(); uint max_map = MAX2(2*parm_cnt+1, jrange->cnt()); // %%% SynchronizationEntryBCI is redundant; use InvocationEntryBci in interfaces assert(SynchronizationEntryBCI == InvocationEntryBci, ""); JVMState* jvms = new (C) JVMState(0); jvms->set_bci(InvocationEntryBci); jvms->set_monoff(max_map); jvms->set_scloff(max_map); jvms->set_endoff(max_map); { SafePointNode *map = new (C) SafePointNode( max_map, jvms ); jvms->set_map(map); set_jvms(jvms); assert(map == this->map(), "kit.map is set"); } // Make up the parameters uint i; for( i = 0; i < parm_cnt; i++ ) map()->init_req(i, _gvn.transform(new (C) ParmNode(start, i))); for( ; i<map()->req(); i++ ) map()->init_req(i, top()); // For nicer debugging // GraphKit requires memory to be a MergeMemNode: set_all_memory(map()->memory()); // Get base of thread-local storage area Node* thread = _gvn.transform( new (C) ThreadLocalNode() ); const int NoAlias = Compile::AliasIdxBot; Node* adr_last_Java_pc = basic_plus_adr(top(), thread, in_bytes(JavaThread::frame_anchor_offset()) + in_bytes(JavaFrameAnchor::last_Java_pc_offset())); #if defined(SPARC) Node* adr_flags = basic_plus_adr(top(), thread, in_bytes(JavaThread::frame_anchor_offset()) + in_bytes(JavaFrameAnchor::flags_offset())); #endif /* defined(SPARC) */ // Drop in the last_Java_sp. last_Java_fp is not touched. // Always do this after the other "last_Java_frame" fields are set since // as soon as last_Java_sp != NULL the has_last_Java_frame is true and // users will look at the other fields. // Node *adr_sp = basic_plus_adr(top(), thread, in_bytes(JavaThread::last_Java_sp_offset())); Node *last_sp = basic_plus_adr(top(), frameptr(), (intptr_t) STACK_BIAS); store_to_memory(NULL, adr_sp, last_sp, T_ADDRESS, NoAlias); // Set _thread_in_native // The order of stores into TLS is critical! Setting _thread_in_native MUST // be last, because a GC is allowed at any time after setting it and the GC // will require last_Java_pc and last_Java_sp. Node* adr_state = basic_plus_adr(top(), thread, in_bytes(JavaThread::thread_state_offset())); //----------------------------- // Compute signature for C call. Varies from the Java signature! const Type **fields = TypeTuple::fields(2*parm_cnt+2); uint cnt = TypeFunc::Parms; // The C routines gets the base of thread-local storage passed in as an // extra argument. Not all calls need it, but its cheap to add here. for( ; cnt<parm_cnt; cnt++ ) fields[cnt] = jdomain->field_at(cnt); fields[cnt++] = TypeRawPtr::BOTTOM; // Thread-local storage // Also pass in the caller's PC, if asked for. if( return_pc ) fields[cnt++] = TypeRawPtr::BOTTOM; // Return PC const TypeTuple* domain = TypeTuple::make(cnt,fields); // The C routine we are about to call cannot return an oop; it can block on // exit and a GC will trash the oop while it sits in C-land. Instead, we // return the oop through TLS for runtime calls. // Also, C routines returning integer subword values leave the high // order bits dirty; these must be cleaned up by explicit sign extension. const Type* retval = (jrange->cnt() == TypeFunc::Parms) ? Type::TOP : jrange->field_at(TypeFunc::Parms); // Make a private copy of jrange->fields(); const Type **rfields = TypeTuple::fields(jrange->cnt() - TypeFunc::Parms); // Fixup oop returns int retval_ptr = retval->isa_oop_ptr(); if( retval_ptr ) { assert( pass_tls, "Oop must be returned thru TLS" ); // Fancy-jumps return address; others return void rfields[TypeFunc::Parms] = is_fancy_jump ? TypeRawPtr::BOTTOM : Type::TOP; } else if( retval->isa_int() ) { // Returning any integer subtype? // "Fatten" byte, char & short return types to 'int' to show that // the native C code can return values with junk high order bits. // We'll sign-extend it below later. rfields[TypeFunc::Parms] = TypeInt::INT; // It's "dirty" and needs sign-ext } else if( jrange->cnt() >= TypeFunc::Parms+1 ) { // Else copy other types rfields[TypeFunc::Parms] = jrange->field_at(TypeFunc::Parms); if( jrange->cnt() == TypeFunc::Parms+2 ) rfields[TypeFunc::Parms+1] = jrange->field_at(TypeFunc::Parms+1); } const TypeTuple* range = TypeTuple::make(jrange->cnt(),rfields); // Final C signature const TypeFunc *c_sig = TypeFunc::make(domain,range); //----------------------------- // Make the call node CallRuntimeNode *call = new (C) CallRuntimeNode(c_sig, C_function, name, TypePtr::BOTTOM); //----------------------------- // Fix-up the debug info for the call call->set_jvms( new (C) JVMState(0) ); call->jvms()->set_bci(0); call->jvms()->set_offsets(cnt); // Set fixed predefined input arguments cnt = 0; for( i=0; i<TypeFunc::Parms; i++ ) call->init_req( cnt++, map()->in(i) ); // A little too aggressive on the parm copy; return address is not an input call->set_req(TypeFunc::ReturnAdr, top()); for( ; i<parm_cnt; i++ ) // Regular input arguments call->init_req( cnt++, map()->in(i) ); call->init_req( cnt++, thread ); if( return_pc ) // Return PC, if asked for call->init_req( cnt++, returnadr() ); _gvn.transform_no_reclaim(call); //----------------------------- // Now set up the return results set_control( _gvn.transform( new (C) ProjNode(call,TypeFunc::Control)) ); set_i_o( _gvn.transform( new (C) ProjNode(call,TypeFunc::I_O )) ); set_all_memory_call(call); if (range->cnt() > TypeFunc::Parms) { Node* retnode = _gvn.transform( new (C) ProjNode(call,TypeFunc::Parms) ); // C-land is allowed to return sub-word values. Convert to integer type. assert( retval != Type::TOP, "" ); if (retval == TypeInt::BOOL) { retnode = _gvn.transform( new (C) AndINode(retnode, intcon(0xFF)) ); } else if (retval == TypeInt::CHAR) { retnode = _gvn.transform( new (C) AndINode(retnode, intcon(0xFFFF)) ); } else if (retval == TypeInt::BYTE) { retnode = _gvn.transform( new (C) LShiftINode(retnode, intcon(24)) ); retnode = _gvn.transform( new (C) RShiftINode(retnode, intcon(24)) ); } else if (retval == TypeInt::SHORT) { retnode = _gvn.transform( new (C) LShiftINode(retnode, intcon(16)) ); retnode = _gvn.transform( new (C) RShiftINode(retnode, intcon(16)) ); } map()->set_req( TypeFunc::Parms, retnode ); } //----------------------------- // Clear last_Java_sp store_to_memory(NULL, adr_sp, null(), T_ADDRESS, NoAlias); // Clear last_Java_pc and (optionally)_flags store_to_memory(NULL, adr_last_Java_pc, null(), T_ADDRESS, NoAlias); #if defined(SPARC) store_to_memory(NULL, adr_flags, intcon(0), T_INT, NoAlias); #endif /* defined(SPARC) */ #ifdef IA64 Node* adr_last_Java_fp = basic_plus_adr(top(), thread, in_bytes(JavaThread::last_Java_fp_offset())); if( os::is_MP() ) insert_mem_bar(Op_MemBarRelease); store_to_memory(NULL, adr_last_Java_fp, null(), T_ADDRESS, NoAlias); #endif // For is-fancy-jump, the C-return value is also the branch target Node* target = map()->in(TypeFunc::Parms); // Runtime call returning oop in TLS? Fetch it out if( pass_tls ) { Node* adr = basic_plus_adr(top(), thread, in_bytes(JavaThread::vm_result_offset())); Node* vm_result = make_load(NULL, adr, TypeOopPtr::BOTTOM, T_OBJECT, NoAlias, false); map()->set_req(TypeFunc::Parms, vm_result); // vm_result passed as result // clear thread-local-storage(tls) store_to_memory(NULL, adr, null(), T_ADDRESS, NoAlias); } //----------------------------- // check exception Node* adr = basic_plus_adr(top(), thread, in_bytes(Thread::pending_exception_offset())); Node* pending = make_load(NULL, adr, TypeOopPtr::BOTTOM, T_OBJECT, NoAlias, false); Node* exit_memory = reset_memory(); Node* cmp = _gvn.transform( new (C) CmpPNode(pending, null()) ); Node* bo = _gvn.transform( new (C) BoolNode(cmp, BoolTest::ne) ); IfNode *iff = create_and_map_if(control(), bo, PROB_MIN, COUNT_UNKNOWN); Node* if_null = _gvn.transform( new (C) IfFalseNode(iff) ); Node* if_not_null = _gvn.transform( new (C) IfTrueNode(iff) ); assert (StubRoutines::forward_exception_entry() != NULL, "must be generated before"); Node *exc_target = makecon(TypeRawPtr::make( StubRoutines::forward_exception_entry() )); Node *to_exc = new (C) TailCallNode(if_not_null, i_o(), exit_memory, frameptr(), returnadr(), exc_target, null()); root()->add_req(_gvn.transform(to_exc)); // bind to root to keep live C->init_start(start); //----------------------------- // If this is a normal subroutine return, issue the return and be done. Node *ret; switch( is_fancy_jump ) { case 0: // Make a return instruction // Return to caller, free any space for return address ret = new (C) ReturnNode(TypeFunc::Parms, if_null, i_o(), exit_memory, frameptr(), returnadr()); if (C->tf()->range()->cnt() > TypeFunc::Parms) ret->add_req( map()->in(TypeFunc::Parms) ); break; case 1: // This is a fancy tail-call jump. Jump to computed address. // Jump to new callee; leave old return address alone. ret = new (C) TailCallNode(if_null, i_o(), exit_memory, frameptr(), returnadr(), target, map()->in(TypeFunc::Parms)); break; case 2: // Pop return address & jump // Throw away old return address; jump to new computed address //assert(C_function == CAST_FROM_FN_PTR(address, OptoRuntime::rethrow_C), "fancy_jump==2 only for rethrow"); ret = new (C) TailJumpNode(if_null, i_o(), exit_memory, frameptr(), target, map()->in(TypeFunc::Parms)); break; default: ShouldNotReachHere(); } root()->add_req(_gvn.transform(ret)); }
void GCPad::LoadDefaults(const ControllerInterface& ciface) { #define set_control(group, num, str) (group)->controls[num]->control_ref->expression = (str) ControllerEmu::LoadDefaults(ciface); // Buttons set_control(m_buttons, 0, "X"); // A set_control(m_buttons, 1, "Z"); // B set_control(m_buttons, 2, "C"); // X set_control(m_buttons, 3, "S"); // Y set_control(m_buttons, 4, "D"); // Z #ifdef _WIN32 set_control(m_buttons, 5, "!LMENU & RETURN"); // Start #else // OS X/Linux set_control(m_buttons, 5, "!`Alt_L` & Return"); // Start #endif // stick modifiers to 50 % m_main_stick->controls[4]->control_ref->range = 0.5f; m_c_stick->controls[4]->control_ref->range = 0.5f; // D-Pad set_control(m_dpad, 0, "T"); // Up set_control(m_dpad, 1, "G"); // Down set_control(m_dpad, 2, "F"); // Left set_control(m_dpad, 3, "H"); // Right // C Stick set_control(m_c_stick, 0, "I"); // Up set_control(m_c_stick, 1, "K"); // Down set_control(m_c_stick, 2, "J"); // Left set_control(m_c_stick, 3, "L"); // Right #ifdef _WIN32 set_control(m_c_stick, 4, "LCONTROL"); // Modifier // Control Stick set_control(m_main_stick, 0, "UP"); // Up set_control(m_main_stick, 1, "DOWN"); // Down set_control(m_main_stick, 2, "LEFT"); // Left set_control(m_main_stick, 3, "RIGHT"); // Right set_control(m_main_stick, 4, "LSHIFT"); // Modifier #elif __APPLE__ set_control(m_c_stick, 4, "Left Control"); // Modifier // Control Stick set_control(m_main_stick, 0, "Up Arrow"); // Up set_control(m_main_stick, 1, "Down Arrow"); // Down set_control(m_main_stick, 2, "Left Arrow"); // Left set_control(m_main_stick, 3, "Right Arrow"); // Right set_control(m_main_stick, 4, "Left Shift"); // Modifier #else // not sure if these are right set_control(m_c_stick, 4, "Control_L"); // Modifier // Control Stick set_control(m_main_stick, 0, "Up"); // Up set_control(m_main_stick, 1, "Down"); // Down set_control(m_main_stick, 2, "Left"); // Left set_control(m_main_stick, 3, "Right"); // Right set_control(m_main_stick, 4, "Shift_L"); // Modifier #endif // Triggers set_control(m_triggers, 0, "Q"); // L set_control(m_triggers, 1, "W"); // R }
static av_cold int init(AVFilterContext *ctx) { LADSPAContext *s = ctx->priv; LADSPA_Descriptor_Function descriptor_fn; const LADSPA_Descriptor *desc; LADSPA_PortDescriptor pd; AVFilterPad pad = { NULL }; char *p, *arg, *saveptr = NULL; unsigned long nb_ports; int i; if (!s->dl_name) { av_log(ctx, AV_LOG_ERROR, "No plugin name provided\n"); return AVERROR(EINVAL); } if (s->dl_name[0] == '/' || s->dl_name[0] == '.') { // argument is a path s->dl_handle = dlopen(s->dl_name, RTLD_LOCAL|RTLD_NOW); } else { // argument is a shared object name char *paths = av_strdup(getenv("LADSPA_PATH")); const char *separator = ":"; if (paths) { p = paths; while ((arg = av_strtok(p, separator, &saveptr)) && !s->dl_handle) { s->dl_handle = try_load(arg, s->dl_name); p = NULL; } } av_free(paths); if (!s->dl_handle && (paths = av_asprintf("%s/.ladspa/lib", getenv("HOME")))) { s->dl_handle = try_load(paths, s->dl_name); av_free(paths); } if (!s->dl_handle) s->dl_handle = try_load("/usr/local/lib/ladspa", s->dl_name); if (!s->dl_handle) s->dl_handle = try_load("/usr/lib/ladspa", s->dl_name); } if (!s->dl_handle) { av_log(ctx, AV_LOG_ERROR, "Failed to load '%s'\n", s->dl_name); return AVERROR(EINVAL); } descriptor_fn = dlsym(s->dl_handle, "ladspa_descriptor"); if (!descriptor_fn) { av_log(ctx, AV_LOG_ERROR, "Could not find ladspa_descriptor: %s\n", dlerror()); return AVERROR(EINVAL); } // Find the requested plugin, or list plugins if (!s->plugin) { av_log(ctx, AV_LOG_INFO, "The '%s' library contains the following plugins:\n", s->dl_name); av_log(ctx, AV_LOG_INFO, "I = Input Channels\n"); av_log(ctx, AV_LOG_INFO, "O = Output Channels\n"); av_log(ctx, AV_LOG_INFO, "I:O %-25s %s\n", "Plugin", "Description"); av_log(ctx, AV_LOG_INFO, "\n"); for (i = 0; desc = descriptor_fn(i); i++) { unsigned long inputs = 0, outputs = 0; count_ports(desc, &inputs, &outputs); av_log(ctx, AV_LOG_INFO, "%lu:%lu %-25s %s\n", inputs, outputs, desc->Label, av_x_if_null(desc->Name, "?")); av_log(ctx, AV_LOG_VERBOSE, "Maker: %s\n", av_x_if_null(desc->Maker, "?")); av_log(ctx, AV_LOG_VERBOSE, "Copyright: %s\n", av_x_if_null(desc->Copyright, "?")); } return AVERROR_EXIT; } else { for (i = 0;; i++) { desc = descriptor_fn(i); if (!desc) { av_log(ctx, AV_LOG_ERROR, "Could not find plugin: %s\n", s->plugin); return AVERROR(EINVAL); } if (desc->Label && !strcmp(desc->Label, s->plugin)) break; } } s->desc = desc; nb_ports = desc->PortCount; s->ipmap = av_calloc(nb_ports, sizeof(*s->ipmap)); s->opmap = av_calloc(nb_ports, sizeof(*s->opmap)); s->icmap = av_calloc(nb_ports, sizeof(*s->icmap)); s->ocmap = av_calloc(nb_ports, sizeof(*s->ocmap)); s->ictlv = av_calloc(nb_ports, sizeof(*s->ictlv)); s->octlv = av_calloc(nb_ports, sizeof(*s->octlv)); s->ctl_needs_value = av_calloc(nb_ports, sizeof(*s->ctl_needs_value)); if (!s->ipmap || !s->opmap || !s->icmap || !s->ocmap || !s->ictlv || !s->octlv || !s->ctl_needs_value) return AVERROR(ENOMEM); for (i = 0; i < nb_ports; i++) { pd = desc->PortDescriptors[i]; if (LADSPA_IS_PORT_AUDIO(pd)) { if (LADSPA_IS_PORT_INPUT(pd)) { s->ipmap[s->nb_inputs] = i; s->nb_inputs++; } else if (LADSPA_IS_PORT_OUTPUT(pd)) { s->opmap[s->nb_outputs] = i; s->nb_outputs++; } } else if (LADSPA_IS_PORT_CONTROL(pd)) { if (LADSPA_IS_PORT_INPUT(pd)) { s->icmap[s->nb_inputcontrols] = i; if (LADSPA_IS_HINT_HAS_DEFAULT(desc->PortRangeHints[i].HintDescriptor)) set_default_ctl_value(s, s->nb_inputcontrols, s->icmap, s->ictlv); else s->ctl_needs_value[s->nb_inputcontrols] = 1; s->nb_inputcontrols++; } else if (LADSPA_IS_PORT_OUTPUT(pd)) { s->ocmap[s->nb_outputcontrols] = i; s->nb_outputcontrols++; } } } // List Control Ports if "help" is specified if (s->options && !strcmp(s->options, "help")) { if (!s->nb_inputcontrols) { av_log(ctx, AV_LOG_INFO, "The '%s' plugin does not have any input controls.\n", desc->Label); } else { av_log(ctx, AV_LOG_INFO, "The '%s' plugin has the following input controls:\n", desc->Label); for (i = 0; i < s->nb_inputcontrols; i++) print_ctl_info(ctx, AV_LOG_INFO, s, i, s->icmap, s->ictlv, 0); } return AVERROR_EXIT; } // Parse control parameters p = s->options; while (s->options) { LADSPA_Data val; int ret; if (!(arg = av_strtok(p, "|", &saveptr))) break; p = NULL; if (sscanf(arg, "c%d=%f", &i, &val) != 2) { av_log(ctx, AV_LOG_ERROR, "Invalid syntax.\n"); return AVERROR(EINVAL); } if ((ret = set_control(ctx, i, val)) < 0) return ret; s->ctl_needs_value[i] = 0; } // Check if any controls are not set for (i = 0; i < s->nb_inputcontrols; i++) { if (s->ctl_needs_value[i]) { av_log(ctx, AV_LOG_ERROR, "Control c%d must be set.\n", i); print_ctl_info(ctx, AV_LOG_ERROR, s, i, s->icmap, s->ictlv, 0); return AVERROR(EINVAL); } } pad.type = AVMEDIA_TYPE_AUDIO; if (s->nb_inputs) { pad.name = av_asprintf("in0:%s%lu", desc->Label, s->nb_inputs); if (!pad.name) return AVERROR(ENOMEM); pad.filter_frame = filter_frame; pad.config_props = config_input; if (ff_insert_inpad(ctx, ctx->nb_inputs, &pad) < 0) { av_freep(&pad.name); return AVERROR(ENOMEM); } } av_log(ctx, AV_LOG_DEBUG, "ports: %lu\n", nb_ports); av_log(ctx, AV_LOG_DEBUG, "inputs: %lu outputs: %lu\n", s->nb_inputs, s->nb_outputs); av_log(ctx, AV_LOG_DEBUG, "input controls: %lu output controls: %lu\n", s->nb_inputcontrols, s->nb_outputcontrols); return 0; }
//------------------------------array_store_check------------------------------ // pull array from stack and check that the store is valid void Parse::array_store_check() { // Shorthand access to array store elements without popping them. Node *obj = peek(0); Node *idx = peek(1); Node *ary = peek(2); if (_gvn.type(obj) == TypePtr::NULL_PTR) { // There's never a type check on null values. // This cutout lets us avoid the uncommon_trap(Reason_array_check) // below, which turns into a performance liability if the // gen_checkcast folds up completely. return; } // Extract the array klass type int klass_offset = oopDesc::klass_offset_in_bytes(); Node* p = basic_plus_adr( ary, ary, klass_offset ); // p's type is array-of-OOPS plus klass_offset Node* array_klass = _gvn.transform( LoadKlassNode::make(_gvn, immutable_memory(), p, TypeInstPtr::KLASS) ); // Get the array klass const TypeKlassPtr *tak = _gvn.type(array_klass)->is_klassptr(); // array_klass's type is generally INexact array-of-oop. Heroically // cast the array klass to EXACT array and uncommon-trap if the cast // fails. bool always_see_exact_class = false; if (MonomorphicArrayCheck && !too_many_traps(Deoptimization::Reason_array_check)) { always_see_exact_class = true; // (If no MDO at all, hope for the best, until a trap actually occurs.) } // Is the array klass is exactly its defined type? if (always_see_exact_class && !tak->klass_is_exact()) { // Make a constant out of the inexact array klass const TypeKlassPtr *extak = tak->cast_to_exactness(true)->is_klassptr(); Node* con = makecon(extak); Node* cmp = _gvn.transform(new (C) CmpPNode( array_klass, con )); Node* bol = _gvn.transform(new (C) BoolNode( cmp, BoolTest::eq )); Node* ctrl= control(); { BuildCutout unless(this, bol, PROB_MAX); uncommon_trap(Deoptimization::Reason_array_check, Deoptimization::Action_maybe_recompile, tak->klass()); } if (stopped()) { // MUST uncommon-trap? set_control(ctrl); // Then Don't Do It, just fall into the normal checking } else { // Cast array klass to exactness: // Use the exact constant value we know it is. replace_in_map(array_klass,con); CompileLog* log = C->log(); if (log != NULL) { log->elem("cast_up reason='monomorphic_array' from='%d' to='(exact)'", log->identify(tak->klass())); } array_klass = con; // Use cast value moving forward } } // Come here for polymorphic array klasses // Extract the array element class int element_klass_offset = in_bytes(ObjArrayKlass::element_klass_offset()); Node *p2 = basic_plus_adr(array_klass, array_klass, element_klass_offset); Node *a_e_klass = _gvn.transform( LoadKlassNode::make(_gvn, immutable_memory(), p2, tak) ); // Check (the hard way) and throw if not a subklass. // Result is ignored, we just need the CFG effects. gen_checkcast( obj, a_e_klass ); }
static void set_leds(int fd, uint32_t value) { set_control(fd, V4L2_CID_HUE, value); }
static int sscape_download_boot(struct sscape_info *devc, unsigned char *block, int size, int flag) { unsigned long flags; unsigned char temp; volatile int done, timeout_val; static unsigned char codec_dma_bits = 0; if (flag & CPF_FIRST) { /* * First block. Have to allocate DMA and to reset the board * before continuing. */ save_flags(flags); cli(); codec_dma_bits = sscape_read(devc, GA_CDCFG_REG); if (devc->dma_allocated == 0) devc->dma_allocated = 1; restore_flags(flags); sscape_write(devc, GA_HMCTL_REG, (temp = sscape_read(devc, GA_HMCTL_REG)) & 0x3f); /*Reset */ for (timeout_val = 10000; timeout_val > 0; timeout_val--) sscape_read(devc, GA_HMCTL_REG); /* Delay */ /* Take board out of reset */ sscape_write(devc, GA_HMCTL_REG, (temp = sscape_read(devc, GA_HMCTL_REG)) | 0x80); } /* * Transfer one code block using DMA */ if (audio_devs[devc->codec_audiodev]->dmap_out->raw_buf == NULL) { printk(KERN_WARNING "soundscape: DMA buffer not available\n"); return 0; } memcpy(audio_devs[devc->codec_audiodev]->dmap_out->raw_buf, block, size); save_flags(flags); cli(); /******** INTERRUPTS DISABLED NOW ********/ do_dma(devc, SSCAPE_DMA_A, audio_devs[devc->codec_audiodev]->dmap_out->raw_buf_phys, size, DMA_MODE_WRITE); /* * Wait until transfer completes. */ done = 0; timeout_val = 30; while (!done && timeout_val-- > 0) { int resid; if (HZ / 50) sleep(HZ / 50); clear_dma_ff(devc->dma); if ((resid = get_dma_residue(devc->dma)) == 0) done = 1; } restore_flags(flags); if (!done) return 0; if (flag & CPF_LAST) { /* * Take the board out of reset */ outb((0x00), PORT(HOST_CTRL)); outb((0x00), PORT(MIDI_CTRL)); temp = sscape_read(devc, GA_HMCTL_REG); temp |= 0x40; sscape_write(devc, GA_HMCTL_REG, temp); /* Kickstart the board */ /* * Wait until the ODB wakes up */ save_flags(flags); cli(); done = 0; timeout_val = 5 * HZ; while (!done && timeout_val-- > 0) { unsigned char x; sleep(1); x = inb(PORT(HOST_DATA)); if (x == 0xff || x == 0xfe) /* OBP startup acknowledge */ { DDB(printk("Soundscape: Acknowledge = %x\n", x)); done = 1; } } sscape_write(devc, GA_CDCFG_REG, codec_dma_bits); restore_flags(flags); if (!done) { printk(KERN_ERR "soundscape: The OBP didn't respond after code download\n"); return 0; } save_flags(flags); cli(); done = 0; timeout_val = 5 * HZ; while (!done && timeout_val-- > 0) { sleep(1); if (inb(PORT(HOST_DATA)) == 0xfe) /* Host startup acknowledge */ done = 1; } restore_flags(flags); if (!done) { printk(KERN_ERR "soundscape: OBP Initialization failed.\n"); return 0; } printk(KERN_INFO "SoundScape board initialized OK\n"); set_control(devc, CTL_MASTER_VOL, 100); set_control(devc, CTL_SYNTH_VOL, 100); #ifdef SSCAPE_DEBUG3 /* * Temporary debugging aid. Print contents of the registers after * downloading the code. */ { int i; for (i = 0; i < 13; i++) printk("I%d = %02x (new value)\n", i, sscape_read(devc, i)); } #endif } return 1; }
int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int cmd, void *arg) { struct saa7146_fh *fh = file->private_data; struct saa7146_dev *dev = fh->dev; struct saa7146_vv *vv = dev->vv_data; int err = 0, result = 0, ee = 0; struct saa7146_use_ops *ops; struct videobuf_queue *q; /* check if extension handles the command */ for(ee = 0; dev->ext_vv_data->ioctls[ee].flags != 0; ee++) { if( cmd == dev->ext_vv_data->ioctls[ee].cmd ) break; } if( 0 != (dev->ext_vv_data->ioctls[ee].flags & SAA7146_EXCLUSIVE) ) { DEB_D(("extension handles ioctl exclusive.\n")); result = dev->ext_vv_data->ioctl(fh, cmd, arg); return result; } if( 0 != (dev->ext_vv_data->ioctls[ee].flags & SAA7146_BEFORE) ) { DEB_D(("extension handles ioctl before.\n")); result = dev->ext_vv_data->ioctl(fh, cmd, arg); if( -EAGAIN != result ) { return result; } } /* fixme: add handle "after" case (is it still needed?) */ switch (fh->type) { case V4L2_BUF_TYPE_VIDEO_CAPTURE: { ops = &saa7146_video_uops; q = &fh->video_q; break; } case V4L2_BUF_TYPE_VBI_CAPTURE: { ops = &saa7146_vbi_uops; q = &fh->vbi_q; break; } default: BUG(); return 0; } switch (cmd) { case VIDIOC_QUERYCAP: { struct v4l2_capability *cap = arg; memset(cap,0,sizeof(*cap)); DEB_EE(("VIDIOC_QUERYCAP\n")); strcpy(cap->driver, "saa7146 v4l2"); strlcpy(cap->card, dev->ext->name, sizeof(cap->card)); sprintf(cap->bus_info,"PCI:%s", pci_name(dev->pci)); cap->version = SAA7146_VERSION_CODE; cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OVERLAY | V4L2_CAP_READWRITE | V4L2_CAP_STREAMING; cap->capabilities |= dev->ext_vv_data->capabilities; return 0; } case VIDIOC_G_FBUF: { struct v4l2_framebuffer *fb = arg; DEB_EE(("VIDIOC_G_FBUF\n")); *fb = vv->ov_fb; fb->capability = V4L2_FBUF_CAP_LIST_CLIPPING; return 0; } case VIDIOC_S_FBUF: { struct v4l2_framebuffer *fb = arg; struct saa7146_format *fmt; DEB_EE(("VIDIOC_S_FBUF\n")); if(!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RAWIO)) return -EPERM; /* check args */ fmt = format_by_fourcc(dev,fb->fmt.pixelformat); if (NULL == fmt) { return -EINVAL; } /* planar formats are not allowed for overlay video, clipping and video dma would clash */ if (0 != (fmt->flags & FORMAT_IS_PLANAR)) { DEB_S(("planar pixelformat '%4.4s' not allowed for overlay\n",(char *)&fmt->pixelformat)); } /* check if overlay is running */ if (IS_OVERLAY_ACTIVE(fh) != 0) { if (vv->video_fh != fh) { DEB_D(("refusing to change framebuffer informations while overlay is active in another open.\n")); return -EBUSY; } } down(&dev->lock); /* ok, accept it */ vv->ov_fb = *fb; vv->ov_fmt = fmt; if (0 == vv->ov_fb.fmt.bytesperline) vv->ov_fb.fmt.bytesperline = vv->ov_fb.fmt.width*fmt->depth/8; up(&dev->lock); return 0; } case VIDIOC_ENUM_FMT: { struct v4l2_fmtdesc *f = arg; int index; switch (f->type) { case V4L2_BUF_TYPE_VIDEO_CAPTURE: case V4L2_BUF_TYPE_VIDEO_OVERLAY: { index = f->index; if (index < 0 || index >= NUM_FORMATS) { return -EINVAL; } memset(f,0,sizeof(*f)); f->index = index; strlcpy(f->description,formats[index].name,sizeof(f->description)); f->pixelformat = formats[index].pixelformat; break; } default: return -EINVAL; } DEB_EE(("VIDIOC_ENUM_FMT: type:%d, index:%d\n",f->type,f->index)); return 0; } case VIDIOC_QUERYCTRL: { const struct v4l2_queryctrl *ctrl; struct v4l2_queryctrl *c = arg; if ((c->id < V4L2_CID_BASE || c->id >= V4L2_CID_LASTP1) && (c->id < V4L2_CID_PRIVATE_BASE || c->id >= V4L2_CID_PRIVATE_LASTP1)) return -EINVAL; ctrl = ctrl_by_id(c->id); if( NULL == ctrl ) { return -EINVAL; /* c->flags = V4L2_CTRL_FLAG_DISABLED; return 0; */ } DEB_EE(("VIDIOC_QUERYCTRL: id:%d\n",c->id)); *c = *ctrl; return 0; } case VIDIOC_G_CTRL: { DEB_EE(("VIDIOC_G_CTRL\n")); return get_control(fh,arg); } case VIDIOC_S_CTRL: { DEB_EE(("VIDIOC_S_CTRL\n")); err = set_control(fh,arg); return err; } case VIDIOC_G_PARM: { struct v4l2_streamparm *parm = arg; if( parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE ) { return -EINVAL; } memset(&parm->parm.capture,0,sizeof(struct v4l2_captureparm)); parm->parm.capture.readbuffers = 1; // fixme: only for PAL! parm->parm.capture.timeperframe.numerator = 1; parm->parm.capture.timeperframe.denominator = 25; return 0; } case VIDIOC_G_FMT: { struct v4l2_format *f = arg; DEB_EE(("VIDIOC_G_FMT\n")); return g_fmt(fh,f); } case VIDIOC_S_FMT: { struct v4l2_format *f = arg; DEB_EE(("VIDIOC_S_FMT\n")); return s_fmt(fh,f); } case VIDIOC_TRY_FMT: { struct v4l2_format *f = arg; DEB_EE(("VIDIOC_TRY_FMT\n")); return try_fmt(fh,f); } case VIDIOC_G_STD: { v4l2_std_id *id = arg; DEB_EE(("VIDIOC_G_STD\n")); *id = vv->standard->id; return 0; } /* the saa7146 supfhrts (used in conjunction with the saa7111a for example) PAL / NTSC / SECAM. if your hardware does not (or does more) -- override this function in your extension */ case VIDIOC_ENUMSTD: { struct v4l2_standard *e = arg; if (e->index < 0 ) return -EINVAL; if( e->index < dev->ext_vv_data->num_stds ) { DEB_EE(("VIDIOC_ENUMSTD: index:%d\n",e->index)); v4l2_video_std_construct(e, dev->ext_vv_data->stds[e->index].id, dev->ext_vv_data->stds[e->index].name); return 0; } return -EINVAL; } case VIDIOC_S_STD: { v4l2_std_id *id = arg; int found = 0; int i, err; DEB_EE(("VIDIOC_S_STD\n")); if ((vv->video_status & STATUS_CAPTURE) == STATUS_CAPTURE) { DEB_D(("cannot change video standard while streaming capture is active\n")); return -EBUSY; } if ((vv->video_status & STATUS_OVERLAY) != 0) { vv->ov_suspend = vv->video_fh; err = saa7146_stop_preview(vv->video_fh); /* side effect: video_status is now 0, video_fh is NULL */ if (0 != err) { DEB_D(("suspending video failed. aborting\n")); return err; } } down(&dev->lock); for(i = 0; i < dev->ext_vv_data->num_stds; i++) if (*id & dev->ext_vv_data->stds[i].id) break; if (i != dev->ext_vv_data->num_stds) { vv->standard = &dev->ext_vv_data->stds[i]; if( NULL != dev->ext_vv_data->std_callback ) dev->ext_vv_data->std_callback(dev, vv->standard); found = 1; } up(&dev->lock); if (vv->ov_suspend != NULL) { saa7146_start_preview(vv->ov_suspend); vv->ov_suspend = NULL; } if( 0 == found ) { DEB_EE(("VIDIOC_S_STD: standard not found.\n")); return -EINVAL; } DEB_EE(("VIDIOC_S_STD: set to standard to '%s'\n",vv->standard->name)); return 0; } case VIDIOC_OVERLAY: { int on = *(int *)arg; int err = 0; DEB_D(("VIDIOC_OVERLAY on:%d\n",on)); if (on != 0) { err = saa7146_start_preview(fh); } else { err = saa7146_stop_preview(fh); } return err; } case VIDIOC_REQBUFS: { struct v4l2_requestbuffers *req = arg; DEB_D(("VIDIOC_REQBUFS, type:%d\n",req->type)); return videobuf_reqbufs(q,req); } case VIDIOC_QUERYBUF: { struct v4l2_buffer *buf = arg; DEB_D(("VIDIOC_QUERYBUF, type:%d, offset:%d\n",buf->type,buf->m.offset)); return videobuf_querybuf(q,buf); } case VIDIOC_QBUF: { struct v4l2_buffer *buf = arg; int ret = 0; ret = videobuf_qbuf(q,buf); DEB_D(("VIDIOC_QBUF: ret:%d, index:%d\n",ret,buf->index)); return ret; } case VIDIOC_DQBUF: { struct v4l2_buffer *buf = arg; int ret = 0; ret = videobuf_dqbuf(q,buf,file->f_flags & O_NONBLOCK); DEB_D(("VIDIOC_DQBUF: ret:%d, index:%d\n",ret,buf->index)); return ret; } case VIDIOC_STREAMON: { int *type = arg; DEB_D(("VIDIOC_STREAMON, type:%d\n",*type)); err = video_begin(fh); if( 0 != err) { return err; } err = videobuf_streamon(q); return err; } case VIDIOC_STREAMOFF: { int *type = arg; DEB_D(("VIDIOC_STREAMOFF, type:%d\n",*type)); /* ugly: we need to copy some checks from video_end(), because videobuf_streamoff() relies on the capture running. check and fix this */ if ((vv->video_status & STATUS_CAPTURE) != STATUS_CAPTURE) { DEB_S(("not capturing.\n")); return 0; } if (vv->video_fh != fh) { DEB_S(("capturing, but in another open.\n")); return -EBUSY; } err = videobuf_streamoff(q); if (0 != err) { DEB_D(("warning: videobuf_streamoff() failed.\n")); video_end(fh, file); } else { err = video_end(fh, file); } return err; } case VIDIOCGMBUF: { struct video_mbuf *mbuf = arg; struct videobuf_queue *q; int i; /* fixme: number of capture buffers and sizes for v4l apps */ int gbuffers = 2; int gbufsize = 768*576*4; DEB_D(("VIDIOCGMBUF \n")); q = &fh->video_q; down(&q->lock); err = videobuf_mmap_setup(q,gbuffers,gbufsize, V4L2_MEMORY_MMAP); if (err < 0) { up(&q->lock); return err; } memset(mbuf,0,sizeof(*mbuf)); mbuf->frames = gbuffers; mbuf->size = gbuffers * gbufsize; for (i = 0; i < gbuffers; i++) mbuf->offsets[i] = i * gbufsize; up(&q->lock); return 0; } default: return v4l_compat_translate_ioctl(inode,file,cmd,arg, saa7146_video_do_ioctl); } return 0; }
void GameControllerManager::process_axis_event(const SDL_ControllerAxisEvent& ev) { // FIXME: buttons and axis are fighting for control ownership, need // to OR the values together //log_info << "axis event: " << static_cast<int>(ev.axis) << " " << ev.value << std::endl; auto controller = m_parent->get_controller(); auto set_control = [this, &controller](Controller::Control control, bool value) { m_stick_state[control] = value; controller->set_control(control, m_button_state[control] || m_stick_state[control]); }; auto axis2button = [this, &set_control](int value, Controller::Control control_left, Controller::Control control_right) { if (value < -m_deadzone) { set_control(control_left, true); set_control(control_right, false); } else if (value > m_deadzone) { set_control(control_left, false); set_control(control_right, true); } else { set_control(control_left, false); set_control(control_right, false); } }; switch(ev.axis) { case SDL_CONTROLLER_AXIS_LEFTX: axis2button(ev.value, Controller::LEFT, Controller::RIGHT); break; case SDL_CONTROLLER_AXIS_LEFTY: axis2button(ev.value, Controller::UP, Controller::DOWN); break; case SDL_CONTROLLER_AXIS_RIGHTX: axis2button(ev.value, Controller::PEEK_LEFT, Controller::PEEK_RIGHT); break; case SDL_CONTROLLER_AXIS_RIGHTY: axis2button(ev.value, Controller::PEEK_UP, Controller::PEEK_DOWN); break; case SDL_CONTROLLER_AXIS_TRIGGERLEFT: break; case SDL_CONTROLLER_AXIS_TRIGGERRIGHT: break; default: break; } }
int do_track_event(unsigned char *data, int *pos) { char channel; unsigned char buf[5]; buf[0]=data[*pos]; *pos +=1; channel = buf[0] & 0xf; #ifdef WANT_MPU401 if (card_info.synth_type==SYNTH_TYPE_MIDI) { switch((buf[0]&0xf0)) { case 0x80: case 0x90: case 0xa0: case 0xb0: case 0xe0: buf[1]=data[*pos]; *pos+=1; buf[2]=data[*pos]; *pos+=1; MIDI_MESSAGE3(buf[0],buf[1],buf[2]); break; case 0xc0: case 0xd0: buf[1]=data[*pos]; *pos+=1; MIDI_MESSAGE3(buf[0],0,buf[1]); break; case 0xf0: return 1; default: return 3; } seqbuf_dump(); return 0; } #endif switch((buf[0] & 0xf0)) { case 0x80: buf[1]=data[*pos]; *pos +=1; buf[2]=data[*pos]; *pos +=1; stop_note((int) channel, (int) buf[1], (int) buf[2]); break; case 0x90: buf[1]=data[*pos]; *pos +=1; buf[2]=data[*pos]; *pos +=1; if(buf[2] == 0) { stop_note((int) channel, (int) buf[1], (int) buf[2]); } else { start_note((int) channel, (int) buf[1], (int) buf[2]); } break; case 0xa0: buf[1]=data[*pos]; *pos +=1; buf[2]=data[*pos]; *pos +=1; set_key_pressure((int) channel, (int) buf[1], (int) buf[2]); break; case 0xb0: buf[1]=data[*pos]; *pos +=1; buf[2]=data[*pos]; *pos +=1; set_control((int) channel, (int) buf[1], (int) buf[2]); break; case 0xe0: buf[1]=data[*pos]; *pos +=1; buf[2]=data[*pos]; *pos +=1; set_pitchbend((int) channel, (int) ((buf[2] << 7) + buf[1]); break; case 0xc0: buf[1]=data[*pos]; *pos +=1; set_program((int) channel, (int) buf[1] ); break; case 0xd0: buf[1]=data[*pos]; *pos +=1; set_chn_pressure((int) channel, (int) buf[1]); break; case 0xf0: return 1; default: return 3; } seqbuf_dump(); return 0; }
void GameControllerManager::process_button_event(const SDL_ControllerButtonEvent& ev) { //log_info << "button event: " << static_cast<int>(ev.button) << " " << static_cast<int>(ev.state) << std::endl; auto controller = m_parent->get_controller(); auto set_control = [this, &controller](Controller::Control control, bool value) { m_button_state[control] = value; controller->set_control(control, m_button_state[control] || m_stick_state[control]); }; switch(ev.button) { case SDL_CONTROLLER_BUTTON_A: set_control(Controller::JUMP, ev.state); set_control(Controller::MENU_SELECT, ev.state); break; case SDL_CONTROLLER_BUTTON_B: set_control(Controller::MENU_BACK, ev.state); break; case SDL_CONTROLLER_BUTTON_X: set_control(Controller::ACTION, ev.state); break; case SDL_CONTROLLER_BUTTON_Y: break; case SDL_CONTROLLER_BUTTON_BACK: set_control(Controller::CONSOLE, ev.state); break; case SDL_CONTROLLER_BUTTON_GUIDE: set_control(Controller::CHEAT_MENU, ev.state); break; case SDL_CONTROLLER_BUTTON_START: set_control(Controller::START, ev.state); break; case SDL_CONTROLLER_BUTTON_LEFTSTICK: break; case SDL_CONTROLLER_BUTTON_RIGHTSTICK: break; case SDL_CONTROLLER_BUTTON_LEFTSHOULDER: set_control(Controller::PEEK_LEFT, ev.state); break; case SDL_CONTROLLER_BUTTON_RIGHTSHOULDER: set_control(Controller::PEEK_RIGHT, ev.state); break; case SDL_CONTROLLER_BUTTON_DPAD_UP: set_control(Controller::UP, ev.state); break; case SDL_CONTROLLER_BUTTON_DPAD_DOWN: set_control(Controller::DOWN, ev.state); break; case SDL_CONTROLLER_BUTTON_DPAD_LEFT: set_control(Controller::LEFT, ev.state); break; case SDL_CONTROLLER_BUTTON_DPAD_RIGHT: set_control(Controller::RIGHT, ev.state); break; default: break; } }