Пример #1
0
static int ssd1351fb_probe(struct spi_device *spi)
{
	struct fb_info *info;
	struct fbtft_par *par;
	int ret;

	fbtft_dev_dbg(DEBUG_DRIVER_INIT_FUNCTIONS, &spi->dev, "%s()\n", __func__);

	info = fbtft_framebuffer_alloc(&ssd1351fb_display, &spi->dev);

	if (!info) return -ENOMEM;

	par = info->par;
	par->spi = spi;

	fbtft_debug_init(par);

	par->fbtftops.init_display  = ssd1351fb_init_display;
	par->fbtftops.set_addr_win  = ssd1351fb_set_addr_win;
	par->fbtftops.verify_gpios  = ssd1351fb_verify_gpios;
	par->fbtftops.blank = blank;
	par->fbtftops.set_gamma = set_gamma;

	ret = fbtft_register_framebuffer(info);

	if (ret >= 0) return 0;

	fbtft_framebuffer_release(info);

	return ret;
}
Пример #2
0
static int sainsmart18fb_probe(struct spi_device *spi)
{
	struct fb_info *info;
	struct fbtft_par *par;
	int ret;

	fbtft_dev_dbg(DEBUG_DRIVER_INIT_FUNCTIONS, &spi->dev, "%s()\n", __func__);

	info = fbtft_framebuffer_alloc(&sainsmart18_display, &spi->dev);
	if (!info)
		return -ENOMEM;

	par = info->par;
	par->spi = spi;
	fbtft_debug_init(par);
	par->fbtftops.init_display = sainsmart18fb_init_display;
	par->fbtftops.verify_gpios = sainsmart18fb_verify_gpios;
	par->fbtftops.register_backlight = fbtft_register_backlight;

	ret = fbtft_register_framebuffer(info);
	if (ret < 0)
		goto out_release;

	return 0;

out_release:
	fbtft_framebuffer_release(info);

	return ret;
}
Пример #3
0
static int ili9341fb_probe(struct spi_device *spi)
{
    struct fb_info *info;
    struct fbtft_par *par;
    int ret;

    fbtft_dev_dbg(DEBUG_DRIVER_INIT_FUNCTIONS, &spi->dev, "%s()\n", __func__);

    info = fbtft_framebuffer_alloc(&ili9341fb_display, &spi->dev);
    if (!info)
        return -ENOMEM;

    par = info->par;
    par->spi = spi;
    fbtft_debug_init(par);
    par->fbtftops.init_display = ili9341fb_init_display;
    par->fbtftops.register_backlight = fbtft_register_backlight;
    par->fbtftops.request_gpios_match = ili9341fb_request_gpios_match;
    par->fbtftops.write_data_command = fbtft_write_data_command8_bus9;
    par->fbtftops.write_vmem = fbtft_write_vmem16_bus9;
    par->fbtftops.set_addr_win = ili9341fb_set_addr_win;

    spi->bits_per_word=9;
    ret = spi->master->setup(spi);
    if (ret) {
        dev_warn(&spi->dev, "9-bit SPI not available, emulating using 8-bit.\n");
        spi->bits_per_word=8;
        ret = spi->master->setup(spi);
        if (ret)
            goto fbreg_fail;

        /* allocate buffer with room for dc bits */
        par->extra = vzalloc(par->txbuf.len + (par->txbuf.len / 8));
        if (!par->extra) {
            ret = -ENOMEM;
            goto fbreg_fail;
        }

        par->fbtftops.write = ili9341fb_write_emulate_9bit;
    }

    ret = fbtft_register_framebuffer(info);
    if (ret < 0)
        goto fbreg_fail;

    return 0;

fbreg_fail:
    if (par->extra)
        vfree(par->extra);
    fbtft_framebuffer_release(info);

    return ret;
}
Пример #4
0
static int flexfb_remove_common(struct device *dev, struct fb_info *info)
{
    fbtft_dev_dbg(DEBUG_DRIVER_INIT_FUNCTIONS, dev, "%s()\n", __func__);

    if (info) {
        fbtft_unregister_framebuffer(info);
        fbtft_framebuffer_release(info);
    }

    return 0;
}
Пример #5
0
static int sainsmart18fb_remove(struct spi_device *spi)
{
	struct fb_info *info = spi_get_drvdata(spi);

	fbtft_dev_dbg(DEBUG_DRIVER_INIT_FUNCTIONS, &spi->dev, "%s()\n", __func__);

	if (info) {
		fbtft_unregister_framebuffer(info);
		fbtft_framebuffer_release(info);
	}

	return 0;
}
Пример #6
0
static int itdb28fb_remove_common(struct device *dev, struct fb_info *info)
{
	fbtft_dev_dbg(DEBUG_DRIVER_INIT_FUNCTIONS, dev, "%s()\n", __func__);

	if (info) {
		fbtft_unregister_framebuffer(info);
		fbtft_framebuffer_release(info);
	}

	sysfs_remove_group(&dev->kobj, &itdb28fb_attr_group);

	return 0;
}
Пример #7
0
static int itdb28fb_probe_common(struct spi_device *sdev, struct platform_device *pdev)
{
	struct device *dev;
	struct fb_info *info;
	struct fbtft_par *par;
	int ret;

	if (sdev)
		dev = &sdev->dev;
	else
		dev = &pdev->dev;

	fbtft_dev_dbg(DEBUG_DRIVER_INIT_FUNCTIONS, dev, "%s()\n", __func__);

	info = fbtft_framebuffer_alloc(&itdb28fb_display, dev);
	if (!info)
		return -ENOMEM;

	par = info->par;
	if (sdev)
		par->spi = sdev;
	else
		par->pdev = pdev;

	fbtft_debug_init(par);
	par->fbtftops.init_display = itdb28fb_init_display;
	par->fbtftops.set_gamma = set_gamma;
	par->fbtftops.register_backlight = fbtft_register_backlight;
	par->fbtftops.write_reg = fbtft_write_reg16_bus8;
	par->fbtftops.set_addr_win = itdb28fb_set_addr_win;
	par->fbtftops.verify_gpios = itdb28fb_verify_gpios;
	if (pdev)
		par->fbtftops.write = fbtft_write_gpio8_wr;

	ret = fbtft_register_framebuffer(info);
	if (ret < 0)
		goto out_release;

    ret = sysfs_create_group(&pdev->dev.kobj, &itdb28fb_attr_group);
    if (ret)
		goto out_release;

	dev_set_drvdata(&pdev->dev, par);
	return 0;

out_release:
	fbtft_framebuffer_release(info);
	return ret;
}
Пример #8
0
static int flexfb_remove_common(struct device *dev, struct fb_info *info)
{
	struct fbtft_par *par;

	if (!info)
		return -EINVAL;
	par = info->par;
	if (par)
		fbtft_par_dbg(DEBUG_DRIVER_INIT_FUNCTIONS, par,
			"%s()\n", __func__);
	fbtft_unregister_framebuffer(info);
	fbtft_framebuffer_release(info);

	return 0;
}
Пример #9
0
static int nokia3310fb_probe(struct spi_device *spi)
{
	struct fb_info *info;
	struct fbtft_par *par;
	int ret;

	fbtft_dev_dbg(DEBUG_DRIVER_INIT_FUNCTIONS, &spi->dev, "%s()\n", __func__);

	if (rotate) {
		nokia3310fb_display.width = HEIGHT;
		nokia3310fb_display.height = WIDTH;
	} else {
		nokia3310fb_display.width = WIDTH;
		nokia3310fb_display.height = HEIGHT;
	}

	info = fbtft_framebuffer_alloc(&nokia3310fb_display, &spi->dev);
	if (!info)
		return -ENOMEM;

	info->fix.visual = FB_VISUAL_MONO10;
	info->var.red.offset =     0;
	info->var.red.length =     0;
	info->var.green.offset =   0;
	info->var.green.length =   0;
	info->var.blue.offset =    0;
	info->var.blue.length =    0;

	par = info->par;
	par->spi = spi;
	fbtft_debug_init(par);
	par->fbtftops.write_data_command = fbtft_write_data_command8_bus8;
	par->fbtftops.verify_gpios = nokia3310fb_verify_gpios;
	par->fbtftops.init_display = nokia3310fb_init_display;
	par->fbtftops.register_backlight = fbtft_register_backlight;
	par->fbtftops.update_display = nokia3310fb_update_display;

	ret = fbtft_register_framebuffer(info);
	if (ret < 0)
		goto out_release;

	return 0;

out_release:
	fbtft_framebuffer_release(info);

	return ret;
}
Пример #10
0
static int ili9341fb_remove(struct spi_device *spi)
{
    struct fb_info *info = spi_get_drvdata(spi);
    struct fbtft_par *par;

    fbtft_dev_dbg(DEBUG_DRIVER_INIT_FUNCTIONS, &spi->dev, "%s()\n", __func__);

    if (info) {
        fbtft_unregister_framebuffer(info);
        par = info->par;
        if (par->extra)
            vfree(par->extra);
        fbtft_framebuffer_release(info);
    }

    return 0;
}
Пример #11
0
static int nokia3310fb_remove(struct spi_device *spi)
{
	struct fb_info *info = spi_get_drvdata(spi);

	fbtft_dev_dbg(DEBUG_DRIVER_INIT_FUNCTIONS, &spi->dev, "%s()\n", __func__);

	if (info) {
		if (info->bl_dev) {
			/* turn off backlight or else it will fade out */
			info->bl_dev->props.power = FB_BLANK_POWERDOWN;
			info->bl_dev->ops->update_status(info->bl_dev);
		}
		fbtft_unregister_framebuffer(info);
		fbtft_framebuffer_release(info);
	}

	return 0;
}
Пример #12
0
static int flexfb_probe_common(struct spi_device *sdev, struct platform_device *pdev)
{
    struct device *dev;
    struct fb_info *info;
    struct fbtft_par *par;
    int ret;

    initp = init;
    initp_num = init_num;

    if (sdev)
        dev = &sdev->dev;
    else
        dev = &pdev->dev;

    fbtft_dev_dbg(DEBUG_DRIVER_INIT_FUNCTIONS, dev, "%s(%s)\n", __func__, sdev ? "'SPI device'" : "'Platform device'");

    if (chip) {

        if (!strcmp(chip, "st7735r")) {
            if (!width)
                width = 128;
            if (!height)
                height = 160;
            if (init_num == 0) {
                initp = st7735r_init;
                initp_num = ARRAY_SIZE(st7735r_init);
            }


        } else if (!strcmp(chip, "hx8340bn")) {
            if (!width)
                width = 176;
            if (!height)
                height = 220;
            setaddrwin = 0;
            if (init_num == 0) {
                initp = hx8340bn_init;
                initp_num = ARRAY_SIZE(hx8340bn_init);
            }


        } else if (!strcmp(chip, "ili9225")) {
            if (!width)
                width = 176;
            if (!height)
                height = 220;
            setaddrwin = 0;
            regwidth = 16;
            if (init_num == 0) {
                initp = ili9225_init;
                initp_num = ARRAY_SIZE(ili9225_init);
            }



        } else if (!strcmp(chip, "ili9320")) {
            if (!width)
                width = 240;
            if (!height)
                height = 320;
            setaddrwin = 1;
            regwidth = 16;
            if (init_num == 0) {
                initp = ili9320_init;
                initp_num = ARRAY_SIZE(ili9320_init);
            }


        } else if (!strcmp(chip, "ili9325")) {
            if (!width)
                width = 240;
            if (!height)
                height = 320;
            setaddrwin = 1;
            regwidth = 16;
            if (init_num == 0) {
                initp = ili9325_init;
                initp_num = ARRAY_SIZE(ili9325_init);
            }

        } else if (!strcmp(chip, "ili9341")) {
            if (!width)
                width = 240;
            if (!height)
                height = 320;
            setaddrwin = 0;
            regwidth = 8;
            if (init_num == 0) {
                initp = ili9341_init;
                initp_num = ARRAY_SIZE(ili9341_init);
            }


        } else if (!strcmp(chip, "ssd1289")) {
            if (!width)
                width = 240;
            if (!height)
                height = 320;
            setaddrwin = 2;
            regwidth = 16;
            if (init_num == 0) {
                initp = ssd1289_init;
                initp_num = ARRAY_SIZE(ssd1289_init);
            }



        } else if (!strcmp(chip, "ssd1351")) {
            if (!width)
                width = 128;
            if (!height)
                height = 128;
            setaddrwin = 3;
            if (init_num == 0) {
                initp = ssd1351_init;
                initp_num = ARRAY_SIZE(ssd1351_init);
            }
        } else {
            dev_err(dev, "chip=%s is not supported\n", chip);
            return -EINVAL;
        }
    }

    if (width == 0 || height == 0) {
        dev_err(dev, "argument(s) missing: width and height has to be set.\n");
        return -EINVAL;
    }
    flex_display.width = width;
    flex_display.height = height;
    fbtft_dev_dbg(DEBUG_DRIVER_INIT_FUNCTIONS, dev, "Display resolution: %dx%d\n", width, height);
    fbtft_dev_dbg(DEBUG_DRIVER_INIT_FUNCTIONS, dev, "chip = %s\n", chip ? chip : "not set");
    fbtft_dev_dbg(DEBUG_DRIVER_INIT_FUNCTIONS, dev, "setaddrwin = %d\n", setaddrwin);
    fbtft_dev_dbg(DEBUG_DRIVER_INIT_FUNCTIONS, dev, "regwidth = %d\n", regwidth);
    fbtft_dev_dbg(DEBUG_DRIVER_INIT_FUNCTIONS, dev, "buswidth = %d\n", buswidth);

    info = fbtft_framebuffer_alloc(&flex_display, dev);
    if (!info)
        return -ENOMEM;

    par = info->par;
    if (sdev)
        par->spi = sdev;
    else
        par->pdev = pdev;
    fbtft_debug_init(par);
    par->fbtftops.init_display = flexfb_init_display;

    /* registerwrite functions */
    switch (regwidth) {
    case 8:
        par->fbtftops.write_reg = fbtft_write_reg8_bus8;
        par->fbtftops.write_data_command = fbtft_write_data_command8_bus8;
        break;
    case 16:
        par->fbtftops.write_reg = fbtft_write_reg16_bus8;
        par->fbtftops.write_data_command = fbtft_write_data_command16_bus8;
        break;
    default:
        dev_err(dev, "argument 'regwidth': %d is not supported.\n", regwidth);
        return -EINVAL;
    }

    /* bus functions */
    if (sdev) {
        switch (buswidth) {
        case 8:
            par->fbtftops.write_vmem = fbtft_write_vmem16_bus8;
            if (!par->startbyte)
                par->fbtftops.verify_gpios = flexfb_verify_gpios_dc;
            break;
        case 9:
            if (regwidth == 16) {
                dev_err(dev, "argument 'regwidth': %d is not supported with buswidth=%d and SPI.\n", regwidth, buswidth);
                return -EINVAL;
            }
            par->fbtftops.write_data_command = fbtft_write_data_command8_bus9;
            par->fbtftops.write_vmem = fbtft_write_vmem16_bus9;
            sdev->bits_per_word=9;
            ret = sdev->master->setup(sdev);
            if (ret) {
                dev_err(dev, "SPI 9-bit setup failed: %d.\n", ret);
                return ret;
            }
            break;
        default:
            dev_err(dev, "argument 'buswidth': %d is not supported with SPI.\n", buswidth);
            return -EINVAL;
        }
        par->fbtftops.write = fbtft_write_spi;
    } else {
        par->fbtftops.verify_gpios = flexfb_verify_gpios_db;
        switch (buswidth) {
        case 8:
            par->fbtftops.write = fbtft_write_gpio8_wr;
            par->fbtftops.write_vmem = fbtft_write_vmem16_bus8;
            break;
        case 16:
            par->fbtftops.write_reg = fbtft_write_reg16_bus16;
            par->fbtftops.write_data_command = fbtft_write_data_command16_bus16;
            if (latched)
                par->fbtftops.write = fbtft_write_gpio16_wr_latched;
            else
                par->fbtftops.write = fbtft_write_gpio16_wr;
            par->fbtftops.write_vmem = fbtft_write_vmem16_bus16;
            break;
        default:
            dev_err(dev, "argument 'buswidth': %d is not supported with parallel.\n", buswidth);
            return -EINVAL;
        }
    }

    /* set_addr_win function */
    switch (setaddrwin) {
    case 0:
        /* use default */
        break;
    case 1:
        par->fbtftops.set_addr_win = flexfb_set_addr_win_1;
        break;
    case 2:
        par->fbtftops.set_addr_win = flexfb_set_addr_win_2;
        break;
    case 3:
        par->fbtftops.set_addr_win = set_addr_win_3;
        break;
    default:
        dev_err(dev, "argument 'setaddrwin': unknown value %d.\n", setaddrwin);
        return -EINVAL;
    }

    if (!nobacklight)
        par->fbtftops.register_backlight = fbtft_register_backlight;

    ret = fbtft_register_framebuffer(info);
    if (ret < 0)
        goto out_release;

    return 0;

out_release:
    fbtft_framebuffer_release(info);

    return ret;
}
Пример #13
0
static int adafruit22fb_probe(struct spi_device *spi)
{
	struct fb_info *info;
	struct fbtft_par *par;
	int ret;

	fbtft_dev_dbg(DEBUG_DRIVER_INIT_FUNCTIONS, &spi->dev, "%s()\n", __func__);

	if (rotate > 3) {
		dev_warn(&spi->dev, "argument 'rotate' illegal value: %d (0-3). Setting it to 0.\n", rotate);
		rotate = 0;
	}
	switch (rotate) {
	case 0:
	case 2:
		adafruit22_display.width = WIDTH;
		adafruit22_display.height = HEIGHT;
		break;
	case 1:
	case 3:
		adafruit22_display.width = HEIGHT;
		adafruit22_display.height = WIDTH;
		break;
	}

	info = fbtft_framebuffer_alloc(&adafruit22_display, &spi->dev);
	if (!info)
		return -ENOMEM;

	par = info->par;
	par->spi = spi;
	fbtft_debug_init(par);
	par->fbtftops.init_display = adafruit22fb_init_display;
	par->fbtftops.register_backlight = fbtft_register_backlight;
	par->fbtftops.write_data_command = fbtft_write_data_command8_bus9;
	par->fbtftops.write_vmem = fbtft_write_vmem16_bus9;
	par->fbtftops.set_addr_win = adafruit22fb_set_addr_win;

	spi->bits_per_word=9;
	ret = spi->master->setup(spi);
	if (ret) {
		dev_warn(&spi->dev, "9-bit SPI not available, emulating using 8-bit.\n");
		spi->bits_per_word=8;
		ret = spi->master->setup(spi);
		if (ret)
			goto fbreg_fail;

		/* allocate buffer with room for dc bits */
		par->extra = vzalloc(par->txbuf.len + (par->txbuf.len / 8));
		if (!par->extra) {
			ret = -ENOMEM;
			goto fbreg_fail;
		}

		par->fbtftops.write = adafruit22fb_write_emulate_9bit;
	}

	ret = fbtft_register_framebuffer(info);
	if (ret < 0)
		goto fbreg_fail;

	return 0;

fbreg_fail:
	if (par->extra)
		vfree(par->extra);
	fbtft_framebuffer_release(info);

	return ret;
}
Пример #14
0
static int __devinit flexfb_probe_common(struct spi_device *sdev, struct platform_device *pdev)
{
	struct device *dev;
	struct fb_info *info;
	struct fbtft_par *par;
	int ret;

	if (sdev)
		dev = &sdev->dev;
	else
		dev = &pdev->dev;

	fbtft_dev_dbg(DEBUG_DRIVER_INIT_FUNCTIONS, dev, "%s(%s)\n", __func__, sdev ? "'SPI device'" : "'Platform device'");

	if (width == 0 || height == 0) {
		dev_err(dev, "argument(s) missing: width and height has to be set.\n");
		return -EINVAL;
	}
	flex_display.width = width;
	flex_display.height = height;
	fbtft_dev_dbg(DEBUG_DRIVER_INIT_FUNCTIONS, dev, "Display size: %dx%d\n", width, height);

	info = fbtft_framebuffer_alloc(&flex_display, dev);
	if (!info)
		return -ENOMEM;

	info->var.rotate = rotate;
	par = info->par;
	if (sdev)
		par->spi = sdev;
	else
		par->pdev = pdev;
	fbtft_debug_init(par);
	par->fbtftops.init_display = flexfb_init_display;

	/* registerwrite functions */
	switch (regwidth) {
	case 8:
		par->fbtftops.write_reg = fbtft_write_reg8_bus8;
		par->fbtftops.write_data_command = fbtft_write_data_command8_bus8;
		break;
	case 16:
		par->fbtftops.write_reg = fbtft_write_reg16_bus8;
		par->fbtftops.write_data_command = fbtft_write_data_command16_bus8;
		break;
	default:
		dev_err(dev, "argument 'regwidth': %d is not supported.\n", regwidth);
		return -EINVAL;
	}

	/* bus functions */
	if (sdev) {
		switch (buswidth) {
		case 8:
			par->fbtftops.write_vmem = fbtft_write_vmem16_bus8;
			par->fbtftops.verify_gpios = flexfb_verify_gpios_dc;
			break;
		case 9:
			if (regwidth == 16) {
				dev_err(dev, "argument 'regwidth': %d is not supported with buswidth=%d and SPI.\n", regwidth, buswidth);
				return -EINVAL;
			}
			par->fbtftops.write_data_command = fbtft_write_data_command8_bus9;
			par->fbtftops.write_vmem = fbtft_write_vmem16_bus9;
			sdev->bits_per_word=9;
			ret = sdev->master->setup(sdev);
			if (ret) {
				dev_err(dev, "SPI 9-bit setup failed: %d.\n", ret);
				return ret;
			}
			break;
		default:
			dev_err(dev, "argument 'buswidth': %d is not supported with SPI.\n", buswidth);
			return -EINVAL;
		}
		par->fbtftops.write = fbtft_write_spi;
	} else {
		switch (buswidth) {
		case 8:
			par->fbtftops.write = fbtft_write_gpio8_wr;
			par->fbtftops.write_vmem = fbtft_write_vmem16_bus8;
			par->fbtftops.verify_gpios = flexfb_verify_gpios_db8;
			break;
		default:
			dev_err(dev, "argument 'buswidth': %d is not supported with parallel.\n", buswidth);
			return -EINVAL;
		}
	}

	/* set_addr_win function */
	switch (setaddrwin) {
	case 0:
		/* use default */
		break;
	case 1:
		par->fbtftops.set_addr_win = flexfb_set_addr_win_1;
		break;
	default:
		dev_err(dev, "argument 'setaddrwin': unknown value %d.\n", setaddrwin);
		return -EINVAL;
	}

	if (!nobacklight)
		par->fbtftops.register_backlight = fbtft_register_backlight;

	ret = fbtft_register_framebuffer(info);
	if (ret < 0)
		goto out_release;

	return 0;

out_release:
	fbtft_framebuffer_release(info);

	return ret;
}