Пример #1
0
static int Colorado_i2c_probe(struct i2c_client *client,
			const struct i2c_device_id *id)
{
	int err = 0;
	struct hdmi *hdmi = NULL;
	struct anx7805_pdata *anx = NULL;
	D("##########Colorado_i2c_probe##############\n");

	memcpy(&g_client, &client, sizeof(client));	
    
	Colorado_init_gpio();
       
	if (!i2c_check_functionality(client->adapter,
				     I2C_FUNC_I2C/*I2C_FUNC_SMBUS_I2C_BLOCK*/)) {
		dev_err(&client->dev, "i2c bus does not support the Colorado\n");
		err = -ENODEV;
		goto exit_kfree;
	}
	
	anx = kzalloc(sizeof(struct anx7805_pdata), GFP_KERNEL);
	if(!anx)
	{
        dev_err(&client->dev, "no memory for state\n");
        goto err_kzalloc_anx;
    }
	anx->client = client;
	anx->dev.detect = 0;
	
	// Register HDMI device
	hdmi = hdmi_register(&client->dev, &anx7805_ops);
	if(hdmi == NULL)
	{
		dev_err(&client->dev, "fail to register hdmi\n");
		goto err_hdmi_register;
	}
	hdmi_set_privdata(hdmi, anx);
	anx->dev.hdmi = hdmi;
	i2c_set_clientdata(client, anx);
	
	err = Colorado_System_Init();
	if (err)
		goto exit_kfree;
	HDMI_task(hdmi);
	queue_delayed_work(hdmi->workqueue, &hdmi->delay_work, 1);
	hdmi_enable(hdmi);
	dev_info(&client->dev, "anx7150 probe ok\n");

	return 0;
	
exit_kfree:
	hdmi_unregister(hdmi);
err_hdmi_register:
	kfree(anx);
	anx = NULL;
err_kzalloc_anx:
	hdmi = NULL;
	dev_err(&client->dev, "anx7805 probe error\n");
	return err;

}
Пример #2
0
static int rk610_hdmi_i2c_probe(struct i2c_client *client,const struct i2c_device_id *id)
{
    int rc = 0;
	struct hdmi *hdmi = NULL;
	struct rkdisplay_platform_data *hdmi_data = client->dev.platform_data;
	
	rk610_hdmi = kzalloc(sizeof(struct rk610_hdmi_pdata), GFP_KERNEL);
	if(!rk610_hdmi)
	{
        dev_err(&client->dev, "no memory for state\n");
        goto err_kzalloc_rk610_hdmi;
    }
	rk610_hdmi->client = client;
	
	if(hdmi_data)
		hdmi = hdmi_register(&client->dev, &rk610_hdmi_ops, hdmi_data->video_source, hdmi_data->property);
	else
		hdmi = hdmi_register(&client->dev, &rk610_hdmi_ops, DISPLAY_SOURCE_LCDC0, DISPLAY_MAIN);
	if(hdmi == NULL)
	{
		dev_err(&client->dev, "fail to register hdmi\n");
		goto err_hdmi_register;
	}
	hdmi->support_r2y = 1;
	rk610_hdmi->hdmi = hdmi;
	hdmi_set_privdata(hdmi, rk610_hdmi);
	i2c_set_clientdata(client, rk610_hdmi);
	
	{
		#ifdef HDMI_USE_IRQ
//		hdmi_changed(hdmi, 0);
		INIT_WORK(&rk610_hdmi->irq_work, rk610_irq_work_func);
		if((rc = gpio_request(client->irq, "hdmi gpio")) < 0)
	    {
	        dev_err(&client->dev, "fail to request gpio %d\n", client->irq);
	        goto err_request_gpio;
	    }
	    rk610_hdmi->irq = gpio_to_irq(client->irq);
		rk610_hdmi->gpio = client->irq;
	    gpio_pull_updown(client->irq,GPIOPullUp);
	    gpio_direction_input(client->irq);
	    if((rc = request_irq(rk610_hdmi->irq, rk610_irq,IRQF_TRIGGER_RISING,NULL,hdmi)) < 0)
	    {
	        dev_err(&client->dev, "fail to request hdmi irq\n");
	        goto err_request_irq;
	    }
		#else
		HDMI_task(hdmi);
		queue_delayed_work(hdmi->workqueue, &hdmi->delay_work, 200);
		#endif
		hdmi_enable(hdmi);
		dev_info(&client->dev, "rk610 hdmi i2c probe ok\n");
	}
	
    return 0;
	
err_request_irq:
	gpio_free(client->irq);
err_request_gpio:
	hdmi_unregister(hdmi);
err_hdmi_register:
	kfree(rk610_hdmi);
	rk610_hdmi = NULL;
err_kzalloc_rk610_hdmi:
	hdmi = NULL;
	dev_err(&client->dev, "rk610 hdmi probe error\n");
	return rc;

}
Пример #3
0
static int anx7150_i2c_probe(struct i2c_client *client,const struct i2c_device_id *id)
{
    int rc = 0;
	struct hdmi *hdmi = NULL;
	struct anx7150_pdata *anx = NULL;
	struct rkdisplay_platform_data *hdmi_data = client->dev.platform_data;
	
	anx = kzalloc(sizeof(struct anx7150_pdata), GFP_KERNEL);
	if(!anx)
	{
        dev_err(&client->dev, "no memory for state\n");
        goto err_kzalloc_anx;
    }
	anx->client = client;
	anx->dev.anx7150_detect = 0;
	anx->init = 1;
	// Register HDMI device
	if(hdmi_data) {
		anx->io_pwr_pin = hdmi_data->io_pwr_pin;
		anx->io_rst_pin = hdmi_data->io_reset_pin;
		hdmi = hdmi_register(&client->dev, &anx7150_ops, hdmi_data->video_source, hdmi_data->property);
	}
	else {
		anx->io_pwr_pin = INVALID_GPIO;
		anx->io_rst_pin = INVALID_GPIO;	
		hdmi = hdmi_register(&client->dev, &anx7150_ops, DISPLAY_SOURCE_LCDC0, DISPLAY_MAIN);
	}
	if(hdmi == NULL)
	{
		dev_err(&client->dev, "fail to register hdmi\n");
		goto err_hdmi_register;
	}
	// Set HDMI private data
	hdmi_set_privdata(hdmi, anx);

    anx->dev.hdmi = hdmi;
	i2c_set_clientdata(client, anx);
	
	//Power on anx7150		
	if(anx->io_pwr_pin != INVALID_GPIO) {
		rc = gpio_request(anx->io_pwr_pin, NULL);
		if(rc) {
			gpio_free(anx->io_pwr_pin);
        	printk(KERN_ERR "request anx7150 power control gpio error\n ");
        	goto err_hdmi_register; 
		}
		else
			gpio_direction_output(anx->io_pwr_pin, GPIO_HIGH);
	}
	
    anx->dev.anx7150_detect = ANX7150_hw_detect_device(anx->client);
	if(anx->dev.anx7150_detect) {
    	HDMI_task(hdmi);
	#ifdef HDMI_USE_IRQ
		hdmi_changed(hdmi, 1);
	    if((rc = gpio_request(client->irq, "hdmi gpio")) < 0)
	    {
	        dev_err(&client->dev, "fail to request gpio %d\n", client->irq);
	        goto err_request_gpio;
	    }
	    anx->irq = gpio_to_irq(client->irq);
		anx->io_irq_pin = client->irq;
	    gpio_pull_updown(client->irq,GPIOPullDown);
	    gpio_direction_input(client->irq);
	    #ifndef CONFIG_ANX7150_IRQ_USE_CHIP
	    anx->init = IRQF_TRIGGER_RISING;
	    if((rc = request_irq(anx->irq, anx7150_detect_irq,IRQF_TRIGGER_RISING,NULL,hdmi)) <0)
	    #else
	    if((rc = request_irq(anx->irq, anx7150_detect_irq,IRQF_TRIGGER_FALLING,NULL,hdmi)) <0)
	    #endif
	    {
	        dev_err(&client->dev, "fail to request hdmi irq\n");
	        goto err_request_irq;
	    }
    #else
		queue_delayed_work(hdmi->workqueue, &hdmi->delay_work, 1);
	#endif
		hdmi_enable(hdmi);
		dev_info(&client->dev, "anx7150 probe ok\n");
	}
    else
    	goto err_request_irq;

    return 0;
	
err_request_irq:
	gpio_free(client->irq);
err_request_gpio:
	hdmi_unregister(hdmi);
err_hdmi_register:
	kfree(anx);
	anx = NULL;
err_kzalloc_anx:
	hdmi = NULL;
	dev_err(&client->dev, "anx7150 probe error\n");
	return rc;

}