static int stmfbio_pre_auth(struct stmfb_info *i) { int res = 0; struct stm_hdmi *hdmi = i->hdmi; ULONG ok; if(!hdmi) return -ENODEV; if(mutex_lock_interruptible(&hdmi->lock)) return -ERESTARTSYS; hdmi->auth = 0; if (STM_DISPLAY_CONNECTED == hdmi->status) { stm_display_output_get_control(hdmi->hdmi_output, STM_CTRL_HDMI_PREAUTH, &ok); if (!ok) { res = -EAGAIN; } } else { res = -ENODEV; } mutex_unlock(&hdmi->lock); return res; }
long stmhdmiio_set_audio_source(unsigned int arg) { unsigned long audio = STM_AV_SOURCE_MAIN_INPUT; unsigned long val; long retval=0; printk("%s - %p\n", __func__, HACK_dev); if(mutex_lock_interruptible(&HACK_dev->lock)) return -ERESTARTSYS; switch(arg) { case STMHDMIIO_AUDIO_SOURCE_2CH_I2S: audio |= STM_AV_SOURCE_2CH_I2S_INPUT; break; case STMHDMIIO_AUDIO_SOURCE_SPDIF: audio |= STM_AV_SOURCE_SPDIF_INPUT; break; case STMHDMIIO_AUDIO_SOURCE_8CH_I2S: audio |= STM_AV_SOURCE_8CH_I2S_INPUT; break; case STMHDMIIO_AUDIO_SOURCE_NONE: break; default: retval = -EINVAL; goto exit; } if(stm_display_output_set_control(HACK_dev->hdmi_output, STM_CTRL_AV_SOURCE_SELECT, audio)<0) { if(signal_pending(current)) retval = -ERESTARTSYS; else retval = -EIO; goto exit; } if(stm_display_output_get_control(HACK_dev->hdmi_output, STM_CTRL_AV_SOURCE_SELECT, &val)<0) { if(signal_pending(current)) retval = -EINTR; else retval = -EIO; goto exit; } if(val != audio) retval = -EINVAL; exit: mutex_unlock(&HACK_dev->lock); return retval; }
long stmhdmiio_get_audio_source(unsigned int * arg) { unsigned long audio; long retval=0; struct stm_hdmi *dev = HACK_dev; printk("%s - %p\n", __func__, dev); if(mutex_lock_interruptible(&dev->lock)) return -ERESTARTSYS; if(stm_display_output_get_control(dev->hdmi_output, STM_CTRL_AV_SOURCE_SELECT, &audio)<0) { if(signal_pending(current)) retval = -EINTR; else retval = -EIO; goto exit; } if (audio & STM_AV_SOURCE_2CH_I2S_INPUT) *arg = STMHDMIIO_AUDIO_SOURCE_2CH_I2S; else if (audio & STM_AV_SOURCE_SPDIF_INPUT) *arg = STMHDMIIO_AUDIO_SOURCE_SPDIF; else if (audio & STM_AV_SOURCE_8CH_I2S_INPUT) *arg = STMHDMIIO_AUDIO_SOURCE_8CH_I2S; else *arg = STMHDMIIO_AUDIO_SOURCE_NONE; exit: mutex_unlock(&dev->lock); return retval; }
static long stmhdmi_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { struct stm_hdmi *dev = (struct stm_hdmi *)filp->private_data; long retval=0; if(mutex_lock_interruptible(&dev->lock)) return -ERESTARTSYS; switch(cmd) { case STMHDMIIO_SET_SPD_DATA: retval = stmhdmi_set_spd_data(dev, arg); break; case STMHDMIIO_SEND_DATA_PACKET: retval = stmhdmi_send_data_packet(dev, arg); break; case STMHDMIIO_SET_ISRC_DATA: retval = stmhdmi_set_isrc_data(dev, arg); break; case STMHDMIIO_FLUSH_DATA_PACKET_QUEUE: stmhdmi_flush_data_packet_queue(dev,arg); break; case STMHDMIIO_SET_AUDIO_DATA: retval = stmhdmi_set_audio_iframe_data(dev, arg); break; case STMHDMIIO_SET_AVMUTE: if(stm_display_output_set_control(dev->hdmi_output, STM_CTRL_AVMUTE, arg)<0) { if(signal_pending(current)) retval = -ERESTARTSYS; else retval = -EIO; } break; case STMHDMIIO_SET_AUDIO_SOURCE: { unsigned long audio = STM_AV_SOURCE_MAIN_INPUT; unsigned long val; switch(arg) { case STMHDMIIO_AUDIO_SOURCE_2CH_I2S: audio |= STM_AV_SOURCE_2CH_I2S_INPUT; break; case STMHDMIIO_AUDIO_SOURCE_SPDIF: audio |= STM_AV_SOURCE_SPDIF_INPUT; break; case STMHDMIIO_AUDIO_SOURCE_8CH_I2S: audio |= STM_AV_SOURCE_8CH_I2S_INPUT; break; case STMHDMIIO_AUDIO_SOURCE_NONE: break; default: retval = -EINVAL; goto exit; } if(stm_display_output_set_control(dev->hdmi_output, STM_CTRL_AV_SOURCE_SELECT, audio)<0) { if(signal_pending(current)) retval = -ERESTARTSYS; else retval = -EIO; goto exit; } if(stm_display_output_get_control(dev->hdmi_output, STM_CTRL_AV_SOURCE_SELECT, &val)<0) { if(signal_pending(current)) retval = -EINTR; else retval = -EIO; goto exit; } if(val != audio) retval = -EINVAL; break; } case STMHDMIIO_SET_AUDIO_TYPE: { unsigned long val; if(stm_display_output_set_control(dev->hdmi_output, STM_CTRL_HDMI_AUDIO_OUT_SELECT, arg)<0) { if(signal_pending(current)) retval = -ERESTARTSYS; else retval = -EIO; goto exit; } if(stm_display_output_get_control(dev->hdmi_output, STM_CTRL_HDMI_AUDIO_OUT_SELECT, &val)<0) { if(signal_pending(current)) retval = -EINTR; else retval = -EIO; goto exit; } if(val != arg) retval = -EINVAL; break; } case STMHDMIIO_SET_OVERSCAN_MODE: { if(arg > STMHDMIIO_SCAN_UNDERSCANNED) { retval = -EINVAL; goto exit; } if(stm_display_output_set_control(dev->hdmi_output, STM_CTRL_HDMI_OVERSCAN_MODE, arg)<0) { if(signal_pending(current)) retval = -ERESTARTSYS; else retval = -EIO; } break; } case STMHDMIIO_SET_CONTENT_TYPE: { ULONG val = 0; if(arg > STMHDMIIO_CE_CONTENT) { retval = -EINVAL; goto exit; } /* * Map the argument to infoframe bits IT|CN1|CN0 */ switch(arg) { case STMHDMIIO_CE_CONTENT: val = 0; break; default: val = arg | (1L<<2); break; } if(stm_display_output_set_control(dev->hdmi_output, STM_CTRL_HDMI_CONTENT_TYPE, val)<0) { if(signal_pending(current)) retval = -ERESTARTSYS; else retval = -EIO; } break; } case STMHDMIIO_SET_EDID_MODE_HANDLING: { unsigned long flags; if(arg > STMHDMIIO_EDID_NON_STRICT_MODE_HANDLING) { retval = -EINVAL; goto exit; } dev->non_strict_edid_semantics = arg; spin_lock_irqsave(&dev->spinlock, flags); if(dev->status != STM_DISPLAY_DISCONNECTED) { dev->status = STM_DISPLAY_NEEDS_RESTART; dev->status_changed = 1; wake_up (&dev->status_wait_queue); } spin_unlock_irqrestore(&dev->spinlock, flags); break; } case STMHDMIIO_SET_HOTPLUG_MODE: { if(arg > STMHDMIIO_HPD_STOP_IF_NECESSARY) { retval = -EINVAL; goto exit; } dev->hotplug_mode = arg; break; } case STMHDMIIO_SET_CEA_MODE_SELECTION: { if(arg > STMHDMIIO_CEA_MODE_FROM_EDID_ASPECT_RATIO) { retval = -EINVAL; goto exit; } switch(arg) { case STMHDMIIO_CEA_MODE_FROM_EDID_ASPECT_RATIO: dev->cea_mode_from_edid = 1; /* * In case the display is already running, change the mode to whatever * the EDID says. Note that if the EDID had bad data we default to * 16:9. */ arg = (dev->edid_info.tv_aspect == STM_WSS_4_3)?STMHDMIIO_CEA_MODE_4_3:STMHDMIIO_CEA_MODE_16_9; break; default: dev->cea_mode_from_edid = 0; break; } if(stm_display_output_set_control(dev->hdmi_output, STM_CTRL_HDMI_CEA_MODE_SELECT, arg)<0) { if(signal_pending(current)) retval = -ERESTARTSYS; else retval = -EIO; } break; } case STMHDMIIO_SET_SAFE_MODE_PROTOCOL: { unsigned long flags; if(dev->hdmi_safe_mode == arg) goto exit; dev->hdmi_safe_mode = arg; spin_lock_irqsave(&dev->spinlock, flags); if(dev->status != STM_DISPLAY_DISCONNECTED) { dev->status = STM_DISPLAY_NEEDS_RESTART; dev->status_changed = 1; wake_up (&dev->status_wait_queue); } spin_unlock_irqrestore(&dev->spinlock, flags); break; } default: retval = -ENOTTY; } exit: mutex_unlock(&dev->lock); return retval; }