static ssize_t hdmi_3d_rda_format_3d(struct device *dev,
	struct device_attribute *attr, char *buf)
{
	ssize_t ret = snprintf(buf, PAGE_SIZE, "%d\n",
		external_common_state->format_3d);
	DEV_DBG("%s: '%d'\n", __func__,
		external_common_state->format_3d);
	return ret;
}
static ssize_t external_common_rda_video_mode_str(struct device *dev,
	struct device_attribute *attr, char *buf)
{
	ssize_t ret = snprintf(buf, PAGE_SIZE, "%s\n",
		video_format_2string(external_common_state->video_resolution));
	DEV_DBG("%s: '%s'\n", __func__,
		video_format_2string(external_common_state->video_resolution));
	return ret;
}
示例#3
0
static ssize_t external_common_rda_video_mode(struct device *dev,
	struct device_attribute *attr, char *buf)
{
	ssize_t ret = snprintf(buf, PAGE_SIZE, "%d\n",
		external_common_state->video_resolution+1);
	DEV_DBG("%s: '%d'\n", __func__,
			external_common_state->video_resolution+1);
	return ret;
}
示例#4
0
文件: nfcsim.c 项目: 19Dan01/linux
static int nfcsim_activate_target(struct nfc_dev *nfc_dev,
				  struct nfc_target *target, u32 protocol)
{
	struct nfcsim *dev = nfc_get_drvdata(nfc_dev);

	DEV_DBG(dev, "\n");

	return -ENOTSUPP;
}
示例#5
0
文件: nfcsim.c 项目: 19Dan01/linux
static int nfcsim_dep_link_down(struct nfc_dev *nfc_dev)
{
	struct nfcsim *dev = nfc_get_drvdata(nfc_dev);

	DEV_DBG(dev, "\n");

	nfcsim_cleanup_dev(dev, 0);

	return 0;
}
static void adv7520_hdcp_enable(struct work_struct *work)
{
	DEV_INFO("HDCP: Start reg[0xaf]=%02x (mute audio)\n", reg[0xaf]);

	adv7520_comm_power(1, 1);

	
	adv7520_write_reg(hclient, 0x0C, (u8)0xC3);

	msleep(200);
	
	
	reg[0xBF] = adv7520_read_reg(hclient, 0xBF);
	reg[0xC0] = adv7520_read_reg(hclient, 0xC0);
	reg[0xC1] = adv7520_read_reg(hclient, 0xC1);
	reg[0xC2] = adv7520_read_reg(hclient, 0xC2);
	reg[0xc3] = adv7520_read_reg(hclient, 0xC3);

	DEV_DBG("HDCP: BKSV={%02x,%02x,%02x,%02x,%02x}\n", reg[0xbf], reg[0xc0],
		reg[0xc1], reg[0xc2], reg[0xc3]);

	
	reg[0xBE] = adv7520_read_reg(hclient, 0xBE);
	if (~(reg[0xBE] & 0x40)) {
		; 
		
	} else {
		
		adv7520_write_reg(hclient, 0x0C, (u8)0x84);
		mutex_lock(&hdcp_state_mutex);
		hdcp_activating = FALSE;
		mutex_unlock(&hdcp_state_mutex);
		DEV_WARN("HDCP: Sink Repeater (%02x), (unmute audio)\n",
			reg[0xbe]);

		adv7520_comm_power(0, 1);
		return;
	}

	msleep(200);
	reg[0xB8] = adv7520_read_reg(hclient, 0xB8);
	DEV_INFO("HDCP: Status reg[0xB8] is %02x\n", reg[0xb8]);
	if (reg[0xb8] & 0x40) {
		
		adv7520_write_reg(hclient, 0x0C, (u8)0x84);
		DEV_INFO("HDCP: A/V content Encrypted (unmute audio)\n");
		external_common_state->hdcp_active = TRUE;
	}
	adv7520_comm_power(0, 1);

	mutex_lock(&hdcp_state_mutex);
	hdcp_activating = FALSE;
	mutex_unlock(&hdcp_state_mutex);
}
示例#7
0
static void adv7520_hdcp_enable(struct work_struct *work)
{
	DEV_INFO("HDCP: Start reg[0xaf]=%02x (mute audio)\n", reg[0xaf]);

	adv7520_comm_power(1, 1);

	/* Mute Audio */
	adv7520_write_reg(hclient, 0x0C, (u8)0xC3);

	msleep(200);
	/* Wait for BKSV ready interrupt */
	/* Read BKSV's keys from HDTV */
	reg[0xBF] = adv7520_read_reg(hclient, 0xBF);
	reg[0xC0] = adv7520_read_reg(hclient, 0xC0);
	reg[0xC1] = adv7520_read_reg(hclient, 0xC1);
	reg[0xC2] = adv7520_read_reg(hclient, 0xC2);
	reg[0xc3] = adv7520_read_reg(hclient, 0xC3);

	DEV_DBG("HDCP: BKSV={%02x,%02x,%02x,%02x,%02x}\n", reg[0xbf], reg[0xc0],
		reg[0xc1], reg[0xc2], reg[0xc3]);

	/* Is SINK repeater */
	reg[0xBE] = adv7520_read_reg(hclient, 0xBE);
	if (~(reg[0xBE] & 0x40)) {
		; /* compare with revocation list */
		/* Check 20 1's and 20 zero's */
	} else {
		/* Don't implement HDCP if sink as a repeater */
		adv7520_write_reg(hclient, 0x0C, (u8)0x84);
		mutex_lock(&hdcp_state_mutex);
		hdcp_activating = FALSE;
		mutex_unlock(&hdcp_state_mutex);
		DEV_WARN("HDCP: Sink Repeater (%02x), (unmute audio)\n",
			reg[0xbe]);

		adv7520_comm_power(0, 1);
		return;
	}

	msleep(200);
	reg[0xB8] = adv7520_read_reg(hclient, 0xB8);
	DEV_INFO("HDCP: Status reg[0xB8] is %02x\n", reg[0xb8]);
	if (reg[0xb8] & 0x40) {
		/* UnMute Audio */
		adv7520_write_reg(hclient, 0x0C, (u8)0x84);
		DEV_INFO("HDCP: A/V content Encrypted (unmute audio)\n");
		external_common_state->hdcp_active = TRUE;
	}
	adv7520_comm_power(0, 1);

	mutex_lock(&hdcp_state_mutex);
	hdcp_activating = FALSE;
	mutex_unlock(&hdcp_state_mutex);
}
示例#8
0
//bool isCarkitConnected=false;
void dp_switch_carkit(bool enable)
{
	//isCarkitConnected=enable;	
	g_otg_state=enable;
	DEV_DBG("%s: dp_switch_carkit is %d++++\n", __func__,enable);
        if(NULL != notify_carkit_in_out_func_ptr)
	{
             printk("[dp] carkit cable notify (%d)\n", enable);
             (*notify_carkit_in_out_func_ptr) (enable);
        }
	
}
示例#9
0
static ssize_t external_common_rda_connected(struct device *dev,
	struct device_attribute *attr, char *buf)
{
	ssize_t ret;
	mutex_lock(&external_common_state_hpd_mutex);
	ret = snprintf(buf, PAGE_SIZE, "%d\n",
		external_common_state->hpd_state);
	DEV_DBG("%s: '%d'\n", __func__,
		external_common_state->hpd_state);
	mutex_unlock(&external_common_state_hpd_mutex);
	return ret;
}
示例#10
0
static irqreturn_t dp_usb_id_detect_handler(int irq, void *dev_id){
	struct anx7808_platform_data *pdata = anx7808_client->dev.platform_data;
	struct anx7808_data *anx7808 = (struct anx7808_data *)dev_id;
	if(gpio_get_value(pdata->gpio_cbl_det)==1)goto exit;
	DEV_DBG("%s: ++++\n", __func__);
	if(gpio_get_value(pdata->gpio_usb_id)==0)
		queue_delayed_work(anx7808->workqueue, &anx7808->carKitwork, 50);
	else
		dp_switch_carkit(false);
		
exit:
	return IRQ_HANDLED;
}
/* ISR for TV out cable detect */
static irqreturn_t tvout_msm_isr(int irq, void *dev_id)
{
	tvout_msm_state->hpd_int_status = TV_IN(TV_INTR_STATUS);
	TV_OUT(TV_INTR_CLEAR, tvout_msm_state->hpd_int_status);
	DEV_DBG("%s: ISR: 0x%02x\n", __func__,
		tvout_msm_state->hpd_int_status & 0x05);

	if (tvenc_pdata->poll)
		if (!tvout_msm_state || !tvout_msm_state->disp_powered_up) {
			DEV_DBG("%s: ISR ignored, display not yet powered on\n",
				__func__);
			return IRQ_HANDLED;
		}
	if (tvout_msm_state->hpd_int_status & BIT(0) ||
		tvout_msm_state->hpd_int_status & BIT(2)) {
		/* Use .75sec to debounce the interrupt */
		mod_timer(&tvout_msm_state->hpd_state_timer, jiffies
			+ msecs_to_jiffies(750));
	}

	return IRQ_HANDLED;
}
示例#12
0
文件: nfcsim.c 项目: 19Dan01/linux
static int nfcsim_target_found(struct nfcsim *dev)
{
	struct nfc_target nfc_tgt;

	DEV_DBG(dev, "\n");

	memset(&nfc_tgt, 0, sizeof(struct nfc_target));

	nfc_tgt.supported_protocols = NFC_PROTO_NFC_DEP_MASK;
	nfc_targets_found(dev->nfc_dev, &nfc_tgt, 1);

	return 0;
}
static int tvout_device_pm_resume(struct device *dev)
{
	mutex_lock(&tvout_msm_state_mutex);
	if (!tvout_msm_state->pm_suspended) {
		mutex_unlock(&tvout_msm_state_mutex);
		return 0;
	}

	if (tvenc_pdata->poll) {
		tvout_msm_state->pm_suspended = FALSE;
		mod_timer(&tvout_msm_state->hpd_work_timer, jiffies
				+ msecs_to_jiffies(TVOUT_HPD_DUTY_CYCLE));
		mutex_unlock(&tvout_msm_state_mutex);
		DEV_DBG("%s: resuming cable detect timer\n", __func__);
	} else {
		tvenc_set_encoder_clock(CLOCK_ON);
		tvout_msm_state->pm_suspended = FALSE;
		mutex_unlock(&tvout_msm_state_mutex);
		enable_irq(tvout_msm_state->irq);
		DEV_DBG("%s: enable cable detect interrupt\n", __func__);
	}
	return 0;
}
示例#14
0
static ssize_t hdmi_3d_wta_format_3d(struct device *dev,
	struct device_attribute *attr, const char *buf, size_t count)
{
	ssize_t ret = strnlen(buf, PAGE_SIZE);
	int format_3d = atoi(buf);

	if (format_3d >= 0 && format_3d <= 2) {
		if (format_3d != external_common_state->format_3d) {
			external_common_state->format_3d = format_3d;
			if (external_common_state->switch_3d)
				external_common_state->switch_3d(format_3d);
			DEV_DBG("%s: '%d'\n", __func__,
				external_common_state->format_3d);
		} else {
			DEV_DBG("%s: '%d' (unchanged)\n", __func__,
				external_common_state->format_3d);
		}
	} else {
		DEV_DBG("%s: '%d' (unknown)\n", __func__, format_3d);
	}

	return ret;
}
示例#15
0
文件: nfcsim.c 项目: 19Dan01/linux
static void nfcsim_stop_poll(struct nfc_dev *nfc_dev)
{
	struct nfcsim *dev = nfc_get_drvdata(nfc_dev);

	DEV_DBG(dev, "Stop poll\n");

	mutex_lock(&dev->lock);

	dev->polling_mode = NFCSIM_POLL_NONE;

	mutex_unlock(&dev->lock);

	cancel_delayed_work_sync(&dev->poll_work);
}
示例#16
0
文件: nfcsim.c 项目: 19Dan01/linux
static int nfcsim_dev_up(struct nfc_dev *nfc_dev)
{
	struct nfcsim *dev = nfc_get_drvdata(nfc_dev);

	DEV_DBG(dev, "\n");

	mutex_lock(&dev->lock);

	dev->up = 1;

	mutex_unlock(&dev->lock);

	return 0;
}
int msm_dss_enable_gpio(struct dss_gpio *in_gpio, int num_gpio, int enable)
{
	int i = 0, rc = 0;
	if (enable) {
		for (i = 0; i < num_gpio; i++) {
			DEV_DBG("%pS->%s: %s enable\n",
				__builtin_return_address(0), __func__,
				in_gpio[i].gpio_name);

			rc = gpio_request(in_gpio[i].gpio,
				in_gpio[i].gpio_name);
			if (rc < 0) {
				DEV_ERR("%pS->%s: %s enable failed\n",
					__builtin_return_address(0), __func__,
					in_gpio[i].gpio_name);
				goto disable_gpio;
			}
			gpio_set_value(in_gpio[i].gpio, in_gpio[i].value);
		}
	} else {
		for (i = num_gpio-1; i >= 0; i--) {
			DEV_DBG("%pS->%s: %s disable\n",
				__builtin_return_address(0), __func__,
				in_gpio[i].gpio_name);
			if (in_gpio[i].gpio)
				gpio_free(in_gpio[i].gpio);
		}
	}
	return rc;

disable_gpio:
	for (i--; i >= 0; i--)
		if (in_gpio[i].gpio)
			gpio_free(in_gpio[i].gpio);

	return rc;
} /* msm_dss_enable_gpio */
示例#18
0
void sp_tx_hardware_recovery(struct i2c_client *client)
{

       struct anx7808_platform_data *pdata = client->dev.platform_data;
       //return;

       gpio_set_value(pdata->gpio_reset, 0);
       msleep(20);
       //gpio_set_value(pdata->gpio_v10_ctrl, 0);
       //msleep(5);
       gpio_set_value(pdata->gpio_p_dwn, 1);
       msleep(20);
 
        DEV_DBG("%s: anx7808 power recovery\n", __func__);
 }
static void tvout_msm_hpd_work(struct work_struct *work)
{
	uint32 reg;

#ifdef CONFIG_SUSPEND
	mutex_lock(&tvout_msm_state_mutex);
	if (tvout_msm_state->pm_suspended) {
		mutex_unlock(&tvout_msm_state_mutex);
		DEV_WARN("%s: ignored, pm_suspended\n", __func__);
		return;
	}
	mutex_unlock(&tvout_msm_state_mutex);
#endif

	/* Enable power lines & clocks */
	tvenc_pdata->pm_vid_en(1);
	tvenc_set_clock(CLOCK_ON);

	/* Enable encoder to get a stable interrupt */
	reg = TV_IN(TV_ENC_CTL);
	TV_OUT(TV_ENC_CTL, reg | TVENC_CTL_ENC_EN);

	/* SW- workaround to update status register */
	reg = TV_IN(TV_DAC_INTF);
	TV_OUT(TV_DAC_INTF, reg & ~TVENC_LOAD_DETECT_EN);
	TV_OUT(TV_INTR_CLEAR, 0xf);
	reg = TV_IN(TV_DAC_INTF);
	TV_OUT(TV_DAC_INTF, reg | TVENC_LOAD_DETECT_EN);

	tvout_msm_state->hpd_int_status = TV_IN(TV_INTR_STATUS);

	/* Disable TV encoder */
	reg = TV_IN(TV_ENC_CTL);
	TV_OUT(TV_ENC_CTL, reg & ~TVENC_CTL_ENC_EN);

	/*Disable power lines & clocks */
	tvenc_set_clock(CLOCK_OFF);
	tvenc_pdata->pm_vid_en(0);

	DEV_DBG("%s: ISR: 0x%02x\n", __func__,
		tvout_msm_state->hpd_int_status & 0x05);

	mod_timer(&tvout_msm_state->hpd_work_timer, jiffies
		+ msecs_to_jiffies(TVOUT_HPD_DUTY_CYCLE));

	tvout_check_status();
}
示例#20
0
文件: nfcsim.c 项目: 19Dan01/linux
static void nfcsim_cleanup_dev(struct nfcsim *dev, u8 shutdown)
{
	DEV_DBG(dev, "shutdown=%d\n", shutdown);

	mutex_lock(&dev->lock);

	dev->polling_mode = NFCSIM_POLL_NONE;
	dev->shutting_down = shutdown;
	dev->cb = NULL;
	dev_kfree_skb(dev->clone_skb);
	dev->clone_skb = NULL;

	mutex_unlock(&dev->lock);

	cancel_delayed_work_sync(&dev->poll_work);
	cancel_delayed_work_sync(&dev->recv_work);
}
static int tvout_device_pm_suspend(struct device *dev)
{
	mutex_lock(&tvout_msm_state_mutex);
	if (tvout_msm_state->pm_suspended) {
		mutex_unlock(&tvout_msm_state_mutex);
		return 0;
	}
	if (tvenc_pdata->poll) {
		if (del_timer(&tvout_msm_state->hpd_work_timer))
			DEV_DBG("%s: suspending cable detect timer\n",
				__func__);
	} else {
		disable_irq(tvout_msm_state->irq);
		tvenc_set_encoder_clock(CLOCK_OFF);
	}
	tvout_msm_state->pm_suspended = TRUE;
	mutex_unlock(&tvout_msm_state_mutex);
	return 0;
}
示例#22
0
文件: nfcsim.c 项目: 19Dan01/linux
static int nfcsim_dep_link_up(struct nfc_dev *nfc_dev,
			      struct nfc_target *target,
			      u8 comm_mode, u8 *gb, size_t gb_len)
{
	int rc;
	struct nfcsim *dev = nfc_get_drvdata(nfc_dev);
	struct nfcsim *peer = dev->peer_dev;
	u8 *remote_gb;
	size_t remote_gb_len;

	DEV_DBG(dev, "target_idx: %d, comm_mode: %d\n", target->idx, comm_mode);

	mutex_lock(&peer->lock);

	nfc_tm_activated(peer->nfc_dev, NFC_PROTO_NFC_DEP_MASK,
			 NFC_COMM_ACTIVE, gb, gb_len);

	remote_gb = nfc_get_local_general_bytes(peer->nfc_dev, &remote_gb_len);
	if (!remote_gb) {
		DEV_ERR(peer, "Can't get remote general bytes\n");

		mutex_unlock(&peer->lock);
		return -EINVAL;
	}

	mutex_unlock(&peer->lock);

	mutex_lock(&dev->lock);

	rc = nfc_set_remote_general_bytes(nfc_dev, remote_gb, remote_gb_len);
	if (rc) {
		DEV_ERR(dev, "Can't set remote general bytes\n");
		mutex_unlock(&dev->lock);
		return rc;
	}

	rc = nfc_dep_link_is_up(nfc_dev, target->idx, NFC_COMM_ACTIVE,
				NFC_RF_INITIATOR);

	mutex_unlock(&dev->lock);

	return rc;
}
/* Change HDMI state */
static void change_hdmi_state(int online)
{
	if (!external_common_state)
		return;

	mutex_lock(&external_common_state_hpd_mutex);
	external_common_state->hpd_state = online;
	mutex_unlock(&external_common_state_hpd_mutex);

	if (!external_common_state->uevent_kobj)
		return;

	if (online)
		kobject_uevent(external_common_state->uevent_kobj,
			KOBJ_ONLINE);
	else
		kobject_uevent(external_common_state->uevent_kobj,
			KOBJ_OFFLINE);
	DEV_DBG("adv7525_uevent: %d\n", online);
}
u32 dss_reg_r(struct dss_io_data *io, u32 offset, u32 debug)
{
	u32 value;
	if (!io || !io->base) {
		DEV_ERR("%pS->%s: invalid input\n",
			__builtin_return_address(0), __func__);
		return -EINVAL;
	}

	if (offset > io->len) {
		DEV_ERR("%pS->%s: offset out of range\n",
			__builtin_return_address(0), __func__);
		return -EINVAL;
	}

	value = readl_relaxed(io->base + offset);
	if (debug)
		DEV_DBG("[%08x] <= %08x\n", (u32)(io->base + offset), value);

	return value;
} /* dss_reg_r */
/* create HDMI kobject and initialize */
int hdmi_common_state_create(struct platform_device *pdev)
{
    int rc;
    struct msm_fb_data_type *mfd = platform_get_drvdata(pdev);

    rc = sysfs_create_group(&mfd->fbi->dev->kobj,
                            &hdmi_common_fs_attr_group);
    if (rc) {
        DEV_ERR("%s: sysfs group creation failed, rc=%d\n", __func__,
                rc);
        return rc;
    }

    hdmi_common_state->uevent_kobj = &mfd->fbi->dev->kobj;
    DEV_ERR("%s: sysfs group %p\n", __func__,
            hdmi_common_state->uevent_kobj);

    kobject_uevent(hdmi_common_state->uevent_kobj, KOBJ_ADD);
    DEV_DBG("%s: kobject_uevent(KOBJ_ADD)\n", __func__);
    return 0;
}
示例#26
0
文件: nfcsim.c 项目: 19Dan01/linux
static int nfcsim_start_poll(struct nfc_dev *nfc_dev,
			     u32 im_protocols, u32 tm_protocols)
{
	struct nfcsim *dev = nfc_get_drvdata(nfc_dev);
	int rc;

	mutex_lock(&dev->lock);

	if (dev->polling_mode != NFCSIM_POLL_NONE) {
		DEV_ERR(dev, "Already in polling mode\n");
		rc = -EBUSY;
		goto exit;
	}

	if (im_protocols & NFC_PROTO_NFC_DEP_MASK)
		dev->polling_mode |= NFCSIM_POLL_INITIATOR;

	if (tm_protocols & NFC_PROTO_NFC_DEP_MASK)
		dev->polling_mode |= NFCSIM_POLL_TARGET;

	if (dev->polling_mode == NFCSIM_POLL_NONE) {
		DEV_ERR(dev, "Unsupported polling mode\n");
		rc = -EINVAL;
		goto exit;
	}

	dev->initiator = 0;
	dev->curr_polling_mode = NFCSIM_POLL_NONE;

	queue_delayed_work(wq, &dev->poll_work, 0);

	DEV_DBG(dev, "Start polling: im: 0x%X, tm: 0x%X\n", im_protocols,
		tm_protocols);

	rc = 0;
exit:
	mutex_unlock(&dev->lock);

	return rc;
}
/* LGE_CHANGE_S [[email protected]] 2011-07-06, Add power_state for NXP HDMI module build */
static ssize_t hdmi_common_wta_power_state(struct device *dev,
	struct device_attribute *attr, const char *buf, size_t count)
{
	ssize_t ret = strnlen(buf, PAGE_SIZE);
	int power_state;
	power_state = atoi(buf);

	if(power_state==1) external_common_state->power_state = 1;
	else if(power_state==0) external_common_state->power_state = 0;
	else external_common_state->power_state = -1;
	DEV_DBG("%s: 'power=%d' successful\n", __func__,
		external_common_state->power_state);

/* LGE_CHANGE_S [[email protected]] 2011-07-06, Add power_state for NXP HDMI module build */
#ifdef CONFIG_LGE_HDMI_MODULE_BUILD
#else
	change_hdmi_power(external_common_state->power_state);
#endif
/* LGE_CHANGE_S [[email protected]] 2011-07-06, Add power_state for NXP HDMI module build */

	return ret;
}
static ssize_t external_common_wta_video_mode(struct device *dev,
	struct device_attribute *attr, const char *buf, size_t count)
{
	ssize_t ret = strnlen(buf, PAGE_SIZE);
	uint32 video_mode;
#ifdef CONFIG_FB_MSM_HDMI_COMMON
	const struct hdmi_disp_mode_timing_type *disp_mode;
#endif
	mutex_lock(&external_common_state_hpd_mutex);
	if (!external_common_state->hpd_state) {
		mutex_unlock(&external_common_state_hpd_mutex);
		DEV_INFO("%s: FAILED: display off or cable disconnected\n",
			__func__);
		return ret;
	}
	mutex_unlock(&external_common_state_hpd_mutex);

	video_mode = atoi(buf)-1;
	kobject_uevent(external_common_state->uevent_kobj, KOBJ_OFFLINE);
#ifdef CONFIG_FB_MSM_HDMI_COMMON
	disp_mode = hdmi_common_get_supported_mode(video_mode);
	if (!disp_mode) {
		DEV_INFO("%s: FAILED: mode not supported (%d)\n",
			__func__, video_mode);
		return ret;
	}
	external_common_state->disp_mode_list.num_of_elements = 1;
	external_common_state->disp_mode_list.disp_mode_list[0] = video_mode;
#elif defined(CONFIG_FB_MSM_TVOUT)
	external_common_state->tvout_enable(0);
	external_common_state->video_resolution = video_mode;
	external_common_state->tvout_enable(1);
#endif
	DEV_DBG("%s: 'mode=%d %s' successful (sending OFF/ONLINE)\n", __func__,
		video_mode, video_format_2string(video_mode));
	kobject_uevent(external_common_state->uevent_kobj, KOBJ_ONLINE);
	return ret;
}
void dss_reg_w(struct dss_io_data *io, u32 offset, u32 value, u32 debug)
{
	u32 in_val;

	if (!io || !io->base) {
		DEV_ERR("%pS->%s: invalid input\n",
			__builtin_return_address(0), __func__);
		return;
	}

	if (offset > io->len) {
		DEV_ERR("%pS->%s: offset out of range\n",
			__builtin_return_address(0), __func__);
		return;
	}

	writel_relaxed(value, io->base + offset);
	if (debug) {
		in_val = readl_relaxed(io->base + offset);
		DEV_DBG("[%08x] => %08x [%08x]\n", (u32)(io->base + offset),
			value, in_val);
	}
} /* dss_reg_w */
static int __devinit tvout_probe(struct platform_device *pdev)
{
	int rc = 0;
	uint32 reg;
	struct platform_device *fb_dev;

#ifdef CONFIG_FB_MSM_TVOUT_NTSC_M
	external_common_state->video_resolution = NTSC_M;
#elif defined CONFIG_FB_MSM_TVOUT_NTSC_J
	external_common_state->video_resolution = NTSC_J;
#elif defined CONFIG_FB_MSM_TVOUT_PAL_M
	external_common_state->video_resolution = PAL_M;
#elif defined CONFIG_FB_MSM_TVOUT_PAL_N
	external_common_state->video_resolution = PAL_N;
#elif defined CONFIG_FB_MSM_TVOUT_PAL_BDGHIN
	external_common_state->video_resolution = PAL_BDGHIN;
#endif
	external_common_state->dev = &pdev->dev;
	if (pdev->id == 0) {
		struct resource *res;

		#define GET_RES(name, mode) do {			\
			res = platform_get_resource_byname(pdev, mode, name); \
			if (!res) {					\
				DEV_DBG("'" name "' resource not found\n"); \
				rc = -ENODEV;				\
				goto error;				\
			}						\
		} while (0)

		#define GET_IRQ(var, name) do {				\
			GET_RES(name, IORESOURCE_IRQ);			\
			var = res->start;				\
		} while (0)

		GET_IRQ(tvout_msm_state->irq, "tvout_device_irq");
		#undef GET_IRQ
		#undef GET_RES
		return 0;
	}

	DEV_DBG("%s: tvout_msm_state->irq : %d",
			__func__, tvout_msm_state->irq);

	rc = request_irq(tvout_msm_state->irq, &tvout_msm_isr,
		IRQF_TRIGGER_HIGH, "tvout_msm_isr", NULL);

	if (rc) {
		DEV_DBG("Init FAILED: IRQ request, rc=%d\n", rc);
		goto error;
	}
	disable_irq(tvout_msm_state->irq);

	init_timer(&tvout_msm_state->hpd_state_timer);
	tvout_msm_state->hpd_state_timer.function =
		tvout_msm_hpd_state_timer;
	tvout_msm_state->hpd_state_timer.data = (uint32)NULL;
	tvout_msm_state->hpd_state_timer.expires = jiffies
						+ msecs_to_jiffies(1000);

	if (tvenc_pdata->poll) {
		init_timer(&tvout_msm_state->hpd_work_timer);
		tvout_msm_state->hpd_work_timer.function =
			tvout_msm_hpd_work_timer;
		tvout_msm_state->hpd_work_timer.data = (uint32)NULL;
		tvout_msm_state->hpd_work_timer.expires = jiffies
						+ msecs_to_jiffies(1000);
	}
	fb_dev = msm_fb_add_device(pdev);
	if (fb_dev) {
		rc = external_common_state_create(fb_dev);
		if (rc) {
			DEV_ERR("Init FAILED: tvout_msm_state_create, rc=%d\n",
				rc);
			goto error;
		}
		if (tvenc_pdata->poll) {
			/* Start polling timer to detect load */
			mod_timer(&tvout_msm_state->hpd_work_timer, jiffies
				+ msecs_to_jiffies(TVOUT_HPD_DUTY_CYCLE));
		} else {
			/* Enable interrupt to detect load */
			tvenc_set_encoder_clock(CLOCK_ON);
			reg = TV_IN(TV_DAC_INTF);
			reg |= TVENC_LOAD_DETECT_EN;
			TV_OUT(TV_DAC_INTF, reg);
			TV_OUT(TV_INTR_ENABLE, 0x5);
			enable_irq(tvout_msm_state->irq);
		}
	} else
		DEV_ERR("Init FAILED: failed to add fb device\n");
error:
	return 0;
}