bool dal_line_buffer_dce110_get_max_num_of_supported_lines( struct line_buffer *lb, enum lb_pixel_depth depth, uint32_t pixel_width, uint32_t *lines) { uint32_t pitch; if (pixel_width == 0) return false; pitch = calculate_pitch(depth, pixel_width); if (pitch == 0 || pitch > LB_ENTRIES_TOTAL_NUMBER) return false; *lines = LB_ENTRIES_TOTAL_NUMBER / pitch; return true; }
static bool brcm_egl_convert_anative_buf_to_khrn_image( android_native_buffer_t *abuffer, KHRN_IMAGE_WRAP_T *khr_image ,bool isTiled) { bool ret = false; if( NULL != khr_image ) { KHRN_IMAGE_FORMAT_T format = convert_android_format( abuffer->format ,isTiled) ; //get the format from the gralloc image #ifdef BRCM_V3D_OPT uint32_t width = abuffer->stride; //get the width from the gralloc image #else uint32_t width = abuffer->width; //get the width from the gralloc image #endif uint32_t height = abuffer->height; //get the width from the gralloc image int32_t stride = calculate_pitch( format, width ); // native_buffer *nbuffer = (native_buffer *)abuffer->handle; struct private_handle_t* nbuffer = (struct private_handle_t*)abuffer->handle; void *storage = nbuffer->p_addr + nbuffer->offset; //get the buffer pointer from the gralloc image - its the 7th item in the structure memset( khr_image, 0, sizeof( KHRN_IMAGE_WRAP_T ) ); if( format != IMAGE_FORMAT_INVALID ) { LOGV("brcm_egl_convert_anative_buf_to_khrn_image - 3" ); khrn_image_wrap( khr_image, format, width, height, stride, storage ); #ifdef BRCM_V3D_OPT khr_image->aux = nbuffer->base; //get the buffer pointer from the gralloc image - its the 7th item in the structure #endif ret = true; } else LOGE("brcm_egl_convert_anative_buf_to_khrn_image - 3" ); } return ret; }
/*This routine is the HNIC. It determines when all the subroutines run. Messing with business in here can have lethal consequences for many things, particularly related to timing. What needs to run when is one of the greatest challenges of this design. */ int main(void) { MIDI_MESSAGE mm_incoming_message; MIDI_MESSAGE *p_mm_incoming_message = &mm_incoming_message; p_global_setting = &global_setting;//assign the pointer to point at the global_setting structure static unsigned char uc_aux_task_state;//keep track of auxilliary task state - filter, lfo, envelope cli();//disable interrupts sys_init(); sei();//enable interrupts initialize_pots(p_global_setting); /*Initialize global_settings. This routine sets some important initial values. Without them, some of the subroutines can be confused because they are expecting certain 0 points that indicate some function is not active.*/ global_setting.auc_synth_params[ADSR_SUSTAIN] = 92; global_setting.auc_synth_params[ADSR_LENGTH] = 127; decode_adsr_length(p_global_setting, 127); global_setting.auc_synth_params[ADSR_DECAY] = 127; global_setting.auc_synth_params[ADSR_RELEASE] = 127; global_setting.auc_ad_values[PITCH_SHIFT] = 127; global_setting.auc_synth_params[PITCH_SHIFT] = 127; global_setting.auc_parameter_source[PITCH_SHIFT] = SOURCE_AD; global_setting.auc_ad_values[AMPLITUDE] = 192; global_setting.auc_synth_params[AMPLITUDE] = 255;//set amplitude global_setting.auc_parameter_source[AMPLITUDE] = SOURCE_AD; global_setting.uc_adsr_multiplier = ADSR_MIN_VALUE;//Initialize the ADSR to its minimum value global_setting.auc_synth_params[PORTAMENTO] = 0; global_setting.auc_synth_params[FILTER_ENV_AMT] = 128; global_setting.auc_synth_params[OSC_MIX] = 127; global_setting.auc_synth_params[OSC_2_WAVESHAPE] = SQUARE; for (; ;) { RESET_WATCHDOG; /*Has the slow interrupt occurred?*/ if(1 == g_uc_slow_interrupt_flag) { //Calculate the adsr envelope value adsr(p_global_setting); //Set the amplitude of the Voltage-Controlled Amplifier set_amplitude(p_global_setting); if(g_un_switch_debounce_timer > 0) { g_un_switch_debounce_timer--; } else if(g_uc_ext_int_0_flag == TRUE) { led_switch_handler(p_global_setting, TACT_LFO_SHAPE); g_uc_ext_int_0_flag = FALSE; CLEAR_EXT_INTERRUPTS; ENABLE_EXT_INT_0; } else if(g_uc_ext_int_1_flag == TRUE) { led_switch_handler(p_global_setting, TACT_LFO_DEST); g_uc_ext_int_1_flag = FALSE; CLEAR_EXT_INTERRUPTS ENABLE_EXT_INT_1; } //Let's handle midi messages. //We have to check the receive uart. //If there is data in the uart receive buffer, check to see //if the incoming fifo has anything in it. If it doesn't have midi messages //waiting to be handled, send it to the incoming midi handler routine. //If there is stuff in the incoming midi fifo, put the new message next in the fifo. if(uart_rx_buffer_has_byte()) { handle_incoming_midi_byte(uart_get_byte()); } /*auxilliary tasks These tasks are handled one at a time, each time through the slow interrupt routine We have to do them one at a time because we can't do them all every time through the loop because we don't have enough clock cycles, nor do we really need to do them that way They are contained in a state machine The number of things to do here affects the timing of them. Adding more things to do will affect timing Just think about it a minute before you do anything crazy like that, but if you must and if you want the envelopes and LFOs to work at specific frequency then you'll have to go through each of the things below */ switch(uc_aux_task_state) { case AUX_TASK_SPI: /*The SPI is shared by the i/o expanders and the digital pots of the filter. These tasks are mutually exclusive though, only one at a time.*/ spi(); uc_aux_task_state = AUX_TASK_READ_AD; break; case AUX_TASK_READ_AD: if(!CHECK_BIT(ADCSRA, ADSC)) { read_ad(p_global_setting); g_uc_ad_ready_flag = 0; } uc_aux_task_state = AUX_TASK_CALC_PITCH; break; case AUX_TASK_CALC_PITCH: calculate_pitch(p_global_setting); uc_aux_task_state = AUX_TASK_LFO; break; case AUX_TASK_LFO: lfo(p_global_setting); uc_aux_task_state = AUX_TASK_MIDI; break; case AUX_TASK_MIDI: //If there are midi messages in the incoming message fifo, handle them. if(g_uc_midi_messages_in_incoming_fifo > 0) { get_midi_message_from_incoming_fifo(p_mm_incoming_message); midi_interpret_incoming_message(p_mm_incoming_message, p_global_setting); } uc_aux_task_state = AUX_TASK_SPI; break; default: break; }//Case statement end //clear the slow interrupt flag g_uc_slow_interrupt_flag = 0; } }//for Loop end return 0; }