s8 dce_mode_program(s32 output_name) { struct output *o=®istry[output_name].output; void *sysname=(void*)udev_device_get_sysname(o->d); //---------------------------------------------------------------------------- //alloc a properly sized double buffered frame buffer o->fb.align=PAGE_SZ;//align on a cpu memory page u64 sz=2*(o->current->h*o->current->v*alga_pixel_fmts_sz[o->pixel_fmt]); o->fb.sz=sz; ul req=IOWR('d',SI_MEM_ALLOC,o->fb); l r=ioctl(o->fd,req,(l)&o->fb); if(ISERR(r)){ PERR("output:%s:dce:unable to allocate proper vram for a frame buffer of" " size %llu bytes\n",sysname,o->fb.sz); goto err; } LOG("output:%s:dce:double buffered frame buffer of %llu bytes allocated\n", sysname,sz); //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- //program synchronously the video mode struct si_dce_dp_set dp_set; dp_set.idx=o->blk_idx; dp_set.primary=o->fb.gpu_addr; dp_set.secondary=o->fb.gpu_addr+sz/2; dp_set.pixel_fmt=o->pixel_fmt; dp_set.timing=*(o->current); dp_set.pitch=o->current->h; req=IOW('d',SI_DCE_DP_SET,dp_set); r=ioctl(o->fd,req,(l)&dp_set); if(ISERR(r)){ PERR("output:%s:dce:%ux%u@%u: unable to program\n",sysname,o->current->h, o->current->v,v_refresh(o->current)); goto err_free_fb; } //---------------------------------------------------------------------------- LOG("output:%s:dce:%ux%u@%u:programmed successfully\n",sysname,o->current->h, o->current->v,v_refresh(o->current)); return LWL_OK; err_free_fb: req=IOW('d',SI_MEM_FREE,o->fb.gpu_addr); r=ioctl(o->fd,req,&o->fb.gpu_addr); if(ISERR(r)) PERR("output:%s:dce:unable to free frame buffer memory (LEAK!)\n",sysname); err: return LWL_ERR; }
void JobAf::restartAllTasks( const std::string & i_message, RenderContainer * i_renders, MonitorContainer * i_monitoring, uint32_t i_state) { for( int b = 0; b < m_blocks_num; b++) { int numtasks = m_blocks_data[b]->getTasksNum(); for( int t = 0; t < numtasks; t++) { m_blocks[b]->m_tasks[t]->restart( i_message, i_renders, i_monitoring, i_state); } } v_refresh( time(NULL), i_renders, i_monitoring); }
s8 dce_mode_select(s32 output_name,void *cfg_mode) { s8 r=LWL_OK; struct output *o=®istry[output_name].output; struct alga_timing *o_timings=&o->dce_info.timings[o->blk_idx][0]; void *sysname=(void*)udev_device_get_sysname(o->d); u8 timing_idx=0; if(*(u8*)cfg_mode!=0){//if cfg file did provide a mode while(1){ if(timing_idx==ALGA_TIMINGS_MAX) break; if(o_timings[timing_idx].pixel_clk==0) break; u8 mode_str[sizeof("hhhhxvvvv@rrr")]; alga_timing_to_str(&mode_str[0],&o_timings[timing_idx]); DCE_LOG("have mode:%s\n",&mode_str[0]); if(strncmp(mode_str,cfg_mode,sizeof("hhhhxvvvv@rrr")-1)==0){ DCE_LOG("mode %s match provided config mode\n",&mode_str[0]); break; } ++timing_idx; } //no timing matching the one provided by cfg file, choose the default one if(timing_idx==ALGA_TIMINGS_MAX||o_timings[timing_idx].pixel_clk==0){ DCE_LOG("config mode %s was not match, selecting mode\n", cfg_mode); timing_idx=0; } } o->current=&o_timings[timing_idx]; o->pixel_fmt=dce_pixel_fmt_select_heuristics(o->blk_idx,&o->dce_info); if(o->pixel_fmt==ALGA_PIXEL_FMT_INVALID){ PERR("output:%s:dce:no pixel format supported\n",sysname); r=LWL_ERR;goto exit; } LOG("output:%s:dce:video mode selected is %ux%u@%u with %s pixel" " format\n",sysname,o->current->h,o->current->v,v_refresh(o->current), alga_pixel_fmts_str[o->pixel_fmt]); exit: return r; }
//in case something is wrong static void alga_timing_to_str(void *mode_str,struct alga_timing *timing) { memset(mode_str,0,sizeof("hhhhxvvvv@rrr")); snprintf(mode_str,sizeof("hhhhxvvvv@rrr"),"%ux%u@%u",timing->h,timing->v, v_refresh(timing)); }
bool JobAf::initialize() { AF_DEBUG << "'" << m_name << "'[" << m_id << "]:"; // // Set job ID to blocks and progress classes: m_progress->setJobId( m_id); for( int b = 0; b < m_blocks_num; b++) { m_blocks_data[b]->setJobId( m_id); } // // Store job ( if not stored ) if( isFromStore() == false ) { setStoreDir( AFCommon::getStoreDirJob( *this)); initStoreDirs(); // Write blocks tasks data: for( int b = 0; b < m_blocks_num; b++) m_blocks[b]->storeTasks(); std::ostringstream ostr; v_jsonWrite( ostr, 0); std::string str = ostr.str(); AFCommon::writeFile( str.c_str(), str.size(), getStoreFile()); } // Create tasks store folder (if does not exists any) if(( af::pathIsFolder( m_store_dir_tasks) == false ) && ( af::pathMakePath( m_store_dir_tasks) == false )) { AFCommon::QueueLogError( std::string("Unable to create tasks store folder:\n") + m_store_dir_tasks); return false; } // // Executing pre commands ( if not from database ) if( isFromStore() == false ) { if( false == m_command_pre.empty()) { AFCommon::executeCmd( m_command_pre); appendLog( std::string("Job pre command executed:\n") + m_command_pre); } for( int b = 0; b < m_blocks_num; b++) { if( m_blocks_data[b]->hasCmdPre() ) { AFCommon::executeCmd( m_blocks_data[b]->getCmdPre()); appendLog( std::string("Block[") + m_blocks_data[b]->getName() + "] pre command executed:\n" + m_blocks_data[b]->getCmdPre()); } } appendLog("Initialized."); } else { appendLog("Initialized from database."); } // // Checking states for( int b = 0; b < m_blocks_num; b++) { int numtasks = m_blocks_data[b]->getTasksNum(); for( int t = 0; t < numtasks; t++) { uint32_t taskstate = m_progress->tp[b][t]->state; if( taskstate == 0 ) { taskstate = AFJOB::STATE_READY_MASK; } else if( taskstate & AFJOB::STATE_RUNNING_MASK && ( false == m_blocks_data[b]->isMultiHost())) { taskstate = taskstate | AFJOB::STATE_WAITRECONNECT_MASK; taskstate = taskstate & (~AFJOB::STATE_RUNNING_MASK ); m_progress->tp[b][t]->time_done = time(NULL); m_blocks[b]->m_tasks[t]->v_appendLog( "Task was running at server start. Waiting for render reconnect..."); } m_progress->tp[b][t]->state = taskstate; } } if(( m_state & AFJOB::STATE_DONE_MASK) == false ) m_state = m_state | AFJOB::STATE_WAITDEP_MASK; v_refresh( time(NULL), NULL, NULL); return true; }