Polysilicon MIS photodetector with internal gain